Last active
December 18, 2015 04:49
-
-
Save replete/5728123 to your computer and use it in GitHub Desktop.
Wrapper for jQuery.syncHeight(). Allows you to have multiple instances on a page with specifically instantiating them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hastily plonked together by @replete, [email protected] | |
/* Use like this: | |
<div class="some-html-chunk" data-sync-height="a-unique-name">Foo</div> | |
<div class="some-other-html-chunk" data-sync-height="a-unique-name">Bar</div> | |
*/ | |
$('[data-sync-height]') | |
.each(function(i,e){ | |
var syncID = $(e).attr('data-sync-height'), | |
$syncHeight = $('[data-sync-height='+ syncID +']'); | |
//Creates load event for each instance, 'namespaced'. | |
$(window) | |
.on('load.sync-height-'+ syncID +' resize.sync-height-'+syncID +' orientationchange.sync-height-'+ syncID, function(){ | |
//Write your own logic here for when to set or unset syncHeight. | |
if (App.breakpointName !== 'default') { | |
$syncHeight.syncHeight(); | |
} else { | |
$syncHeight.unSyncHeight(); | |
} | |
}) | |
.trigger('resize.sync-height-'+syncID); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment