From 75f41069adce6c31312323c76f7e48ff8d07cf13 Mon Sep 17 00:00:00 2001 From: ahodesuka Date: Mon, 20 Feb 2012 00:08:37 -0600 Subject: [PATCH] Add an option to only expand images which have not been scrolled past when using the expand all button. --- 4chan_x.user.js | 9 ++++++++- script.coffee | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e365c8737..96bc0d33b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -100,6 +100,7 @@ Imaging: { 'Image Auto-Gif': [false, 'Animate gif thumbnails'], 'Image Expansion': [true, 'Expand images'], + 'Expand All (Unscrolled)': [false, 'Expand all images will only expand those which you have not scrolled past'], 'Image Hover': [false, 'Show full image on mouseover'], 'Sauce': [true, 'Add sauce to images'], 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] @@ -3392,7 +3393,13 @@ _ref = $$('img[md5]'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { thumb = _ref[_i]; - imgExpand.expand(thumb); + if (conf['Expand All (Unscrolled)']) { + if (thumb.getBoundingClientRect().bottom >= 0) { + imgExpand.expand(thumb); + } + } else { + imgExpand.expand(thumb); + } } } else { _ref2 = $$('img[md5][hidden]'); diff --git a/script.coffee b/script.coffee index 0b8a6c988..0227df801 100644 --- a/script.coffee +++ b/script.coffee @@ -22,6 +22,7 @@ config = Imaging: 'Image Auto-Gif': [false, 'Animate gif thumbnails'] 'Image Expansion': [true, 'Expand images'] + 'Expand All (Unscrolled)': [false, 'Expand all images will only expand those which you have not scrolled past'] 'Image Hover': [false, 'Show full image on mouseover'] 'Sauce': [true, 'Add sauce to images'] 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] @@ -2663,7 +2664,11 @@ imgExpand = imgExpand.on = @checked if imgExpand.on #expand for thumb in $$ 'img[md5]' - imgExpand.expand thumb + if conf['Expand All (Unscrolled)'] + if thumb.getBoundingClientRect().bottom >= 0 + imgExpand.expand thumb + else + imgExpand.expand thumb else #contract for thumb in $$ 'img[md5][hidden]' imgExpand.contract thumb