Skip to content

Commit 330b343

Browse files
author
Matt Swanson
committed
scroll view when opening with j/k, fixes stringer-rss#98. only scroll with n/p when item is offscreen, fixes stringer-rss#80
1 parent 9765381 commit 330b343

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

app.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def t(*args)
6262
"/js/bootstrap-min.js",
6363
"/js/bootstrap.file-input.js",
6464
"/js/mousetrap-min.js",
65+
"/js/jquery-visible-min.js",
6566
"/js/underscore-min.js",
6667
"/js/backbone-min.js",
6768
"/js/app.js"

app/public/js/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ var StoryView = Backbone.View.extend({
9797
if (this.model.get("open")) {
9898
this.$el.addClass("open");
9999
$(".story-lead", this.$el).fadeOut(1000);
100+
window.scrollTo(0, this.$el.offset().top);
100101
} else {
101102
this.$el.removeClass("open");
102103
$(".story-lead", this.$el).show();
@@ -105,6 +106,7 @@ var StoryView = Backbone.View.extend({
105106

106107
itemSelected: function() {
107108
this.$el.toggleClass("cursor", this.model.get("selected"));
109+
if (!this.$el.visible()) window.scrollTo(0, this.$el.offset().top);
108110
},
109111

110112
storyClicked: function() {

app/public/js/jquery-visible-min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)