From 8f29d8eac9421bf26fc1ce127b783760ecaeb2a8 Mon Sep 17 00:00:00 2001 From: ahodesuka Date: Wed, 18 Jan 2012 22:55:16 -0600 Subject: [PATCH] Replace ternary operator with simple if --- 4chan_x.user.js | 8 ++++++-- script.coffee | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 053ea029c..fa37d7b68 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2995,8 +2995,12 @@ thumb = a.firstChild; if (thumb.hidden) { rect = a.getBoundingClientRect(); - d.body.scrollTop += rect.top < 0 ? rect.top + thumb.height / (rect.height / rect.top * -1) : 0; - d.body.scrollLeft += rect.left < 0 ? rect.left + thumb.width / (rect.width / rect.left * -1) : 0; + if (rect.top < 0) { + d.body.scrollTop += rect.top + thumb.height / (rect.height / rect.top * -1); + } + if (rect.left < 0) { + d.body.scrollLeft += rect.left + thumb.width / (rect.width / rect.left * -1); + } return imgExpand.contract(thumb); } else { return imgExpand.expand(thumb); diff --git a/script.coffee b/script.coffee index b21c55485..25be94ca4 100644 --- a/script.coffee +++ b/script.coffee @@ -2317,8 +2317,8 @@ imgExpand = thumb = a.firstChild if thumb.hidden rect = a.getBoundingClientRect() - d.body.scrollTop += if rect.top < 0 then rect.top + thumb.height / (rect.height / rect.top * -1) else 0 - d.body.scrollLeft += if rect.left < 0 then rect.left + thumb.width / (rect.width / rect.left * -1) else 0 + d.body.scrollTop += rect.top + thumb.height / (rect.height / rect.top * -1) if rect.top < 0 + d.body.scrollLeft += rect.left + thumb.width / (rect.width / rect.left * -1) if rect.left < 0 imgExpand.contract thumb else imgExpand.expand thumb