Skip to content

Commit

Permalink
DEV: Remove safari hacks (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
hnb-ku committed Nov 26, 2019
1 parent 13dfd68 commit 34fd9df
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions common/header.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<script type="text/discourse-plugin" version="0.1">
<script type="text/discourse-plugin"
version="0.1">
const minimumOffset = require("discourse/lib/offset-calculator").minimumOffset;
const { iconHTML } = require("discourse-common/lib/icon-library");
const { run } = Ember;

const mobileView = $("html").hasClass("mobile-view");
const isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
const scrollElemnt = isSafari ? "body" : "html";

const linkIcon = iconHTML("hashtag");
const closeIcon = iconHTML("times");
Expand Down Expand Up @@ -168,7 +167,7 @@
},

highlightItemsOnScroll: self => {
$(scrollElemnt)
$('html, body')
.promise()
.done(function() {
const winScrollTop = $(window).scrollTop();
Expand Down Expand Up @@ -226,21 +225,17 @@
.not(elem)
.not(elem.parent(".d-toc-subheading:has(.d-toc-active)"));

return isSafari
? target.fadeOut(TOC_ANIMATION_SPEED)
: target.slideUp(TOC_ANIMATION_SPEED);
return target.slideUp(TOC_ANIMATION_SPEED);
},

show: function(elem) {
return isSafari
? elem.fadeIn(TOC_ANIMATION_SPEED)
: elem.slideDown(TOC_ANIMATION_SPEED);
return elem.slideDown(TOC_ANIMATION_SPEED);
},

scrollTo: function(elem) {
const currentDiv = $(`[data-d-toc="${elem.attr("data-d-toc")}"]`);

$(scrollElemnt).animate(
$('html, body').animate(
{
scrollTop: `${currentDiv.offset().top - minimumOffset()}`
},
Expand Down Expand Up @@ -391,4 +386,4 @@
}
});
}
</script>
</script>

0 comments on commit 34fd9df

Please sign in to comment.