Permalink
Browse files

Data-inview: Ensure that elements removed from the DOM don't trigger …

…data-inview.
  • Loading branch information...
thomasgohard committed May 13, 2015
1 parent ef31d7a commit 88bc8ce8af4d86d1763884a29e6ba619e4f47776
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/plugins/data-inview/data-inview.js
@@ -70,7 +70,21 @@ var componentName = "wb-inview",
// partial - part of the element is in the viewport
// none - no part of the element is in the viewport
viewState = ( scrollBottom > y2 && scrollTop < y1 ) ? "all" : inView ? "none" : "partial",
$dataInView, show;
$dataInView = $( "#" + $elm.attr( "data-inview" ) ),
show;
// Remove any element that no longer exists in the DOM
if ( elementWidth === 0 || elementHeight === 0 ) {
$elms = $elms.not( $elm );
$dataInView.addClass( "user-closed" );
$dataInView.trigger( {
type: ( "close" ),
namespace: "wb-overlay",
noFocus: true
} );
return;
}
// Only if the view state has changed
if ( viewState !== oldViewState ) {
@@ -79,7 +93,6 @@ var componentName = "wb-inview",
show = inView || ( $elm.hasClass( "show-none" ) ? false : viewState === "partial" );
$elm.attr( "data-inviewstate", viewState );
$dataInView = $( "#" + $elm.attr( "data-inview" ) );
if ( $dataInView.length !== 0 ) {

0 comments on commit 88bc8ce

Please sign in to comment.