Skip to content

Conversation

@miketierney
Copy link

The current implementation only allows the following use cases:

$('#my_node').anystretch('path/to/image');

and

$.anystretch('path/to/image');

I have a scenario where I'd like to have this work like a proper module, grabbing a collection of nodes and then applying the anystretch function to them:

<div class="js-stretch-image" data-img-src="/path/to/img01"></div>
<div class="js-stretch-image" data-img-src="/path/to/img02"></div>
<div class="js-stretch-image" data-img-src="/path/to/img03"></div>

Which I could enable by doing something like this:

$('.js-stretch-image').anystretch($(this).data('imgSrc')); // ideal, but not really functional

or

$('.js-stretch-image').each(function(i, el){ // less than ideal, but more flexible
  $(el).anystretch($(el).data('imgSrc'));
});

The problem lies with the use of this.selector as the toggle for whether or not the isBody Boolean is true or not. My patch changes it to check for whether or not this.context is undefined (true when executed from $.anystretch() and false when $('.selector').anystretch()).

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

Successfully merging this pull request may close these issues.

1 participant