flickity icon indicating copy to clipboard operation
flickity copied to clipboard

createMethods not working in v3.0.0

Open aaronstezycki opened this issue 2 years ago • 2 comments

Currently, using V3 and applying some older techniques to Flickity results in some console errors. I am using the equal cells size height hack which is a "extra" on this page: https://flickity.metafizzy.co/extras.html.

The console error comes from this line:

Flickity.createMethods.push('_createResizeClass');

Obviously, this worked in version 2.3, and now doesn't on v3. Just wondering what the code is now to continue pushing custom methods to Flickity?

** Test Case :** Just change Flickity version to use v3 instead of v2: https://codepen.io/desandro/pen/ZXEGVq

aaronstezycki avatar Jan 30 '23 13:01 aaronstezycki

Ah, have just seen #1210, not sure if you can pin that to the top :)

Hopefully my issue is of future help to you with regards to updating documentation and examples. :)

aaronstezycki avatar Jan 30 '23 14:01 aaronstezycki

Ah, sorry about that. I'm going to add a fix to add backwards compatibility for that createMethods API.

For future reference. here is old v2 code...

// v2
Flickity.prototype._createResizeClass = function() {
  this.element.classList.add('flickity-resize');
};

Flickity.createMethods.push('_createResizeClass');

In Flickity, v3, you attach the method to Flickity.create instead. No push needed.

// v3
Flickity.create._createResizeClass = function() {
  this.element.classList.add('flickity-resize');
};

desandro avatar Feb 06 '23 01:02 desandro