diff options
author | Michael Crawford <michael@crawford.io> | 2019-08-09 18:58:40 +0300 |
---|---|---|
committer | Michael Crawford <michael@crawford.io> | 2019-08-09 18:58:40 +0300 |
commit | ce6bec3d2175689eeea90b62a48a98bba7c5029b (patch) | |
tree | 12d6f6526b96546579f09710aefb3903ef0ca8b6 | |
parent | 215907266f463fd75d79113c2e9e792ea39dc57f (diff) |
Fix preview scroll issue
When the image preview was expanded in the grid, the window
was scrolling incorrectly in the positionPreview function
of the Preview prototype.
-rw-r--r-- | layouts/_default/baseof.html | 2 | ||||
-rw-r--r-- | static/js/grid.js | 14 |
2 files changed, 4 insertions, 12 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b6cc570..eeacab6 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -7,7 +7,7 @@ {{- block "main" . }}{{- end }} </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> - <script src="/js/grid.js?v=0.3.3"></script> + <script src="/js/grid.js?v=0.3.4"></script> <script> $(function() { Grid.init(); diff --git a/static/js/grid.js b/static/js/grid.js index 4bebe96..e22695e 100644 --- a/static/js/grid.js +++ b/static/js/grid.js @@ -294,7 +294,7 @@ var Grid = (function() { } Preview.prototype = { - create : function() { // need to add dimensions and mediums here + create : function() { this.$title = $('<h3></h3>'); this.$description = $('<p></p>'); this.$mediums = $('<p></p>'); @@ -431,17 +431,9 @@ var Grid = (function() { } }, positionPreview : function() { - var position = this.$item.data('offsetTop'), + var position = this.$item.data( 'offsetTop' ), previewOffsetTop = this.$previewElement.offset().top - scrollExtra, - scrollValue = this.height + this.$item.data('height'); - - if (marginExpanded <= winSize.height) { - scrollValue = position; - } else if (this.height < winSize.height) { - scrollValue = previewOffsetTop - (winSize.height - this.height) - } else { - scrollValue = previewOffsetTop; - } + scrollValue = this.height + this.$item.data( 'height' ) + marginExpanded <= winSize.height ? position : this.height < winSize.height ? previewOffsetTop - ( winSize.height - this.height ) : previewOffsetTop; $body.animate({scrollTop : scrollValue}, settings.speed); }, |