-
Notifications
You must be signed in to change notification settings - Fork 429
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
Dynamically added images #93
Dynamically added images #93
Conversation
@@ -171,6 +171,10 @@ | |||
return regex.test(element.href); | |||
}); | |||
var gallery = []; | |||
|
|||
if(tagsNodeList.length === 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces after if and before the bracket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
388b6b4
to
a92ac4e
Compare
unbind(imageElement, 'click', imagedEventHandlers[galleryID + '_' + imageElement]); | ||
}); | ||
imagesMap.pop(); | ||
for(var selector in data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a space after keywords like if
, for
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a92ac4e
to
1067976
Compare
@alexdrimbe: make sure there are not new JSHint issues in your branch. |
There are no JSHint issues introduced by the new code. |
@alexdrimbe: please fetch and rebase, |
1067976
to
ad3cd01
Compare
@@ -148,50 +146,75 @@ | |||
supports.svg = testSVGSupport(); | |||
|
|||
buildOverlay(); | |||
destroyGalleriesForSelector(selector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we destroy on run() ? I'm not sure I understand the function's responsibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we call run() function multiple times for the same selector we want to destroy any cached data for selector and unbind its listeners.
@alexdrimbe could you summarize this PR? I've already forgotten the essence of the change, besides significant code improvements (btw. great job!). |
@feimosi this PR could be summarize as follows: If you dynamically add or remove DOM elements from the gallery and then you call baguetteBox.run( someSelector ) again for the same selector the gallery works fine. Before, if you called 'run' function multiple times for the same selector, the click event was attached multiple times for the same elements and this is a source for memory leak; Now if you call run function multiple times it works properly. |
… will replace it in foreach call
…leries, imagesMap imagedEventHandlers currentGallery becomes an array For the moment we delete unbindImageClickListeners
ad3cd01
to
9e5c800
Compare
9e5c800
to
b2606ef
Compare
b2606ef
to
4356ffd
Compare
Ok, we're good to go with this PR. Really good job @alexdrimbe, thank you! |
No description provided.