Skip to content

Commit

Permalink
Use imagesLoaded jQuery extension instead of window.load
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj committed Feb 11, 2016
1 parent 3671275 commit 2a20939
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions UofM_2.info
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ stylesheets[print][] = css/print.css
; Optionally add some JavaScripts to your theme.

scripts[] = js/script.js
scripts[] = js/jquery.selectBoxIt.min.js

scripts[] = js/imagesloaded.pkgd.min.js


; This section lists the regions defined in Zen's default page.tpl.php and
Expand Down
7 changes: 7 additions & 0 deletions js/imagesloaded.pkgd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
});

// Scroll active compound into view.
if (jQuery('.islandora-compound-thumbs, .islandora-compound-jail-thumbs').length > 0) {
jQuery('.islandora-compound-thumbs, .islandora-compound-jail-thumbs').imagesLoaded(function() {
var active = jQuery('.islandora-compound-thumb a.active:visible, .islandora-compound-object-jail-active:visible');
var activeLeft = jQuery(active).offset().left;
var wrapWidth = jQuery('.islandora-compound-thumbs-wrapper, .islandora-compound-jail-thumbs').width();
var wrapLeft = jQuery('.islandora-compound-thumbs-wrapper, .islandora-compound-jail-thumbs').offset().left;
if (activeLeft > (wrapLeft + wrapWidth)){
jQuery(active).scrollParent().animate({'scrollLeft': (activeLeft - wrapLeft - (wrapWidth / 2)) + 'px'},500);
}
}
});

// Show and hide captions from new grid display.
if (jQuery('.islandora-newspaper-issue, .solr-grid-thumb, .islandora-basic-collection-thumb').length > 0) {
Expand Down

0 comments on commit 2a20939

Please sign in to comment.