From b9d402d62bd988281c6705856c36d8ceffaac22c Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Mon, 20 Feb 2017 14:45:39 -0500 Subject: [PATCH] Fixes issue with visibility type image re-animating when reinitialized --- RELEASE-NOTES.md | 1 + src/definitions/behaviors/visibility.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 0673fcfb9..0da8f3b95 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -32,6 +32,7 @@ - **Form Validation** - Fixes js error caused by revalidating inputs without validation rules #4497 #4547 **Thanks @cbxp** - **Input/Dropdown** - Fixed rounding error causing vertical alignment of `dropdown`, `search`, `input` to sometimes appear off by 1 pixel #4279 - **Segment** - Fixed `padded vertical segment` `very padded vertical segment` would receive horizontal padding #3012 +- **Visibility* - Fixes issue where reinitializing, `.visibility({ type: 'image'})` will cause it to re-animate when visibile again **Documentation** - **Visibility** - Added documentation for `onOnscreen` and `onOffScreen` to important callbacks somehow omitted from docs diff --git a/src/definitions/behaviors/visibility.js b/src/definitions/behaviors/visibility.js index f2f186cc0..73aeecf17 100644 --- a/src/definitions/behaviors/visibility.js +++ b/src/definitions/behaviors/visibility.js @@ -387,7 +387,11 @@ $.fn.visibility = function(parameters) { .attr('src', src) ; if(settings.transition) { - if( $.fn.transition !== undefined ) { + if( $.fn.transition !== undefined) { + if($module.hasClass(className.visible)) { + module.debug('Transition already occurred on this image, skipping animation'); + return; + } $module.transition(settings.transition, settings.duration, callback); } else { @@ -1270,7 +1274,8 @@ $.fn.visibility.settings = { className: { fixed : 'fixed', - placeholder : 'placeholder' + placeholder : 'placeholder', + visible : 'visible' }, error : {