(el: any)
| 98 | removedObject = undefined |
| 99 | } |
| 100 | public addObject(el: any) { |
| 101 | |
| 102 | let wH = window.innerHeight |
| 103 | el.setAttribute(`data-string-id`, attr(el, `data-string-id`, `${this._key}-${this.id}`)) |
| 104 | el.classList.add(attr(el, `data-string-id`, `${this._key}-${this.id}`)) |
| 105 | el.setAttribute(`${this._key}-inited`, true) |
| 106 | let stringObject = new StringScrollObject(el, this.progressKey, this.progressFactorKey, this.bufferProgressKey) |
| 107 | this.allObjects.set(attr(el, `data-string-id`), stringObject) |
| 108 | this.objectsMap.set(attr(el, `data-string-id`), stringObject) |
| 109 | let callbackShow = (es: any) => { |
| 110 | es.forEach((e: any) => { |
| 111 | if (e.isIntersecting) { |
| 112 | this.eventManager.emit(`intersection_${stringObject.key}_${stringObject.id}`, true) |
| 113 | this.onEnter(stringObject, null) |
| 114 | } else { |
| 115 | this.eventManager.emit(`intersection_${stringObject.key}_${stringObject.id}`, false) |
| 116 | this.onLeave(stringObject, null) |
| 117 | } |
| 118 | this.objectsArray = Array.from(this.objectsMap).map(([name, value]) => (value)) |
| 119 | }) |
| 120 | } |
| 121 | let callbackGl = (es: any) => { |
| 122 | es.forEach((e: any) => { |
| 123 | if (e.isIntersecting) { |
| 124 | let id = attr(e.target, `data-string-id`, `${this._key}-${this.id}`) |
| 125 | this.objectsMap.set(id, stringObject) |
| 126 | } else { |
| 127 | let id = attr(e.target, `data-string-id`, `${this._key}-${this.id}`) |
| 128 | this.objectsMap.delete(id) |
| 129 | } |
| 130 | this.objectsArray = Array.from(this.objectsMap).map(([name, value]) => (value)) |
| 131 | }) |
| 132 | } |
| 133 | let optionsProgress = { |
| 134 | root: null, |
| 135 | rootMargin: `${stringObject.oBottom * 1 + 10 }px 0px ${stringObject.oTop * 1 + 10}px 0px`, |
| 136 | threshold: 0.001, |
| 137 | } |
| 138 | let optionsShow = { |
| 139 | root: null, |
| 140 | rootMargin: `${stringObject.oTop}px 0px ${stringObject.oBottom}px 0px`, |
| 141 | threshold: 0.001, |
| 142 | } |
| 143 | |
| 144 | |
| 145 | |
| 146 | let obGl = new IntersectionObserver(callbackGl, optionsProgress); |
| 147 | let obShow = new IntersectionObserver(callbackShow, optionsShow); |
| 148 | |
| 149 | obGl.observe(el); |
| 150 | obShow.observe(el); |
| 151 | |
| 152 | stringObject.showObserver = obShow |
| 153 | stringObject.progressObserver = obGl |
| 154 | |
| 155 | this.id++ |
| 156 | } |
| 157 | public scrollEmit(data: StringAnimationData){ |
no test coverage detected