DEV: Remove safari hacks (#6)
This commit is contained in:
parent
13dfd68bc9
commit
34fd9dff66
|
@ -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");
|
||||
|
@ -168,7 +167,7 @@
|
|||
},
|
||||
|
||||
highlightItemsOnScroll: self => {
|
||||
$(scrollElemnt)
|
||||
$('html, body')
|
||||
.promise()
|
||||
.done(function() {
|
||||
const winScrollTop = $(window).scrollTop();
|
||||
|
@ -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()}`
|
||||
},
|
||||
|
@ -391,4 +386,4 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</script>
|
Loading…
Reference in New Issue