Skip to content

Commit

Permalink
Merge pull request #468 from trln/rescope-viewport-js-function
Browse files Browse the repository at this point in the history
move def of isInViewport function to safer scope
  • Loading branch information
kazymovae authored Nov 11, 2024
2 parents 12c075b + 702ffe5 commit a4e1ca1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions app/assets/javascripts/trln_argon/expand_contract.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// test if an element is in the viewport
$.fn.isInViewport = function() {
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
};

Blacklight.onLoad(function() {

/**
* Tests whether an element is vertically
* contained within the current viewport
**/
$.fn.isInViewport = function() {
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
};

$("#documents .hider, #holdings .hider").click(function(evt) {
evt.preventDefault();
var theAnchorID = $(this).attr('href');
Expand Down

0 comments on commit a4e1ca1

Please sign in to comment.