-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar-right.js
93 lines (81 loc) · 2.3 KB
/
sidebar-right.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import Component from "@ember/component"
import { computed } from "@ember/object"
import $ from "jquery"
export default Component.extend({
mouseIsIn: false,
// fakeIndex: computed('hello', function () {
// console.log('computed once');
// return this.get('hello') ? this.get('hello') : "empty now";
// }),
prevSectionClick: false,
shutUp: false,
didInsertElement() {
this._super(...arguments)
this.firstActive()
// BIND SCROLL
const listOfTopArr = $(".markdown-header")
const contentListArr = $(".directionStyle")
$(window).on("mousewheel", function() {
const scrollPos = $(window).scrollTop()
for (let i = 0; i < listOfTopArr.length - 1; i++) {
if (scrollPos < listOfTopArr.eq(0).offset().top) {
contentListArr
.removeClass("active")
.eq(0)
.addClass("active")
} else if (scrollPos > listOfTopArr.eq(i).offset().top - 110) {
contentListArr
.removeClass("active")
.eq(i)
.addClass("active")
} else if ($(window).scrollTop() + $(window).height() == $(document).height()) {
contentListArr
.removeClass("active")
.eq(listOfTopArr.length - 1)
.addClass("active")
}
}
})
},
mouseDown() {},
mouseUp() {},
willDestroyElement() {
this._super(...arguments)
$(window).unbind("scroll")
},
firstActive() {
$(".directionStyle")
.removeClass("active")
.eq(0)
.addClass("active")
},
// TODO: replace mouse enter with other
// mouseEnter(event) {
// this.set("mouseIsIn", true)
// return false
// },
// mouseLeave(event) {
// this.set("mouseIsIn", false)
// return false
// },
actions: {
changeHello() {
this.incrementProperty("hello", 5)
},
scrollTopPos(id) {
$(".directionStyle").removeClass("active")
const elmnt = document.getElementsByClassName("directionStyle")[id]
elmnt.classList.add("active")
const currentIdName = elmnt.childNodes[0].getAttribute("data-attr")
$([document.documentElement, document.body]).animate(
{
scrollTop: $(`#${currentIdName}`).offset().top - 100,
},
200,
() => {
// console.log('work');
}
)
},
},
})