Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: $frames.filter(...).sort is not a function #581

Open
BackuPs opened this issue Aug 25, 2024 · 2 comments
Open

Uncaught TypeError: $frames.filter(...).sort is not a function #581

BackuPs opened this issue Aug 25, 2024 · 2 comments

Comments

@BackuPs
Copy link

BackuPs commented Aug 25, 2024

I am testing jquery 4.0.0 beta 2 i get a error ( Uncaught TypeError: $frames.filter(...).sort is not a function) because the .sort() is removed from jquery. The slider stops working.

Any idea how to fix this?

`
function frameAppend ($frames, $shaft, type) {
if (!frameAppend[type]) {

  var thumbsFLAG = type === 'nav' && o_navThumbs,
      left = 0;

  $shaft.append(
    $frames
        .filter(function () {
          var actual,
              $this = $(this),
              frameData = $this.data();
          for (var _i = 0, _l = data.length; _i < _l; _i++) {
            if (frameData.data === data[_i]) {
              actual = true;
              frameData.eq = _i;
              break;
            }
          }
          return actual || $this.remove() && false;
        })
        .sort(function (a, b) {
          return $(a).data().eq - $(b).data().eq;
        })
        .each(function () {

          if (!thumbsFLAG) return;

          var $this = $(this),
              frameData = $this.data(),
              thumbwidth = Math.round(o_thumbSide2 * frameData.data.thumbratio) || o_thumbSide;

          frameData.l = left;
          frameData.w = thumbwidth;

          $this.css({width: thumbwidth});

          left += thumbwidth + opts.thumbmargin;
        })
  );

  frameAppend[type] = true;
}

}`

@BackuPs
Copy link
Author

BackuPs commented Aug 26, 2024

You need to rewrite the function to this

`

	  function frameAppend ($frames, $shaft, type) {
		if (!frameAppend[type]) {

			var thumbsFLAG = type === 'nav' && o_navThumbs,
			  left = 0;

			$frames.filter(function () {
				  var actual,
					  $this = $(this),
					  frameData = $this.data();
				  for (var _i = 0, _l = data.length; _i < _l; _i++) {
					if (frameData.data === data[_i]) {
					  actual = true;
					  frameData.eq = _i;
					  break;
					}
				  }
				  return actual || $this.remove() && false;
			});
			[].sort.call( $frames, function (a, b) {
				  return $(a).data().eq - $(b).data().eq;
			});

			$shaft.append(
				$frames
					.each(function () {

					  if (!thumbsFLAG) return;

					  var $this = $(this),
						  frameData = $this.data(),
						  thumbwidth = Math.round(o_thumbSide2 * frameData.data.thumbratio) || o_thumbSide;

					  frameData.l = left;
					  frameData.w = thumbwidth;

					  $this.css({width: thumbwidth});

					  left += thumbwidth + opts.thumbmargin;
					})
			);
			frameAppend[type] = true;
		}
	  }
	  
	  
	  `

Also change all $.now() to Date.now()

After these changes it will work with jQuery 4.0

On request i can provide the complete fotorama js file.

@BackuPs
Copy link
Author

BackuPs commented Aug 27, 2024

The full fixed fotorama.js for jquery 4.0 can be downloaded here

https://pastebin.com/k5VeBXMT

the minified versions is here

https://pastebin.com/p6wdvcq7

or grab them directly from my forked version

https://github.com/BackuPs/fotorama/tree/master/src/js

the files are called fotorama.dev.js & fotorama.dev.min.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant