js-kompo-utils 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -214,15 +214,16 @@ export default {
214
214
  window.addEventListener('resize', this._onResize, { passive: true })
215
215
 
216
216
  if (window.visualViewport) {
217
- this._onViewportChange = () => {
217
+ this._onViewportScroll = () => {
218
218
  if (this._rafId) return
219
219
  this._rafId = requestAnimationFrame(() => {
220
220
  this._rafId = null
221
- this.refresh()
221
+ this.trackPosition()
222
222
  })
223
223
  }
224
- window.visualViewport.addEventListener('resize', this._onViewportChange)
225
- window.visualViewport.addEventListener('scroll', this._onViewportChange)
224
+ this._onViewportResize = () => this.refresh()
225
+ window.visualViewport.addEventListener('scroll', this._onViewportScroll)
226
+ window.visualViewport.addEventListener('resize', this._onViewportResize)
226
227
  }
227
228
 
228
229
  const opts = this.$refs.selectOptions
@@ -243,10 +244,17 @@ export default {
243
244
  })
244
245
  if (anchor) this._anchorObserver.observe(anchor)
245
246
  }
246
- if (typeof IntersectionObserver !== 'undefined' && anchor) {
247
+ const inOverlay = !!(anchor && anchor.closest('.kompoModal, .kompoDrawer, .vl-sidebar-l'))
248
+ if (inOverlay && typeof IntersectionObserver !== 'undefined' && anchor) {
249
+ let intersectionInitialised = false
247
250
  this._anchorIntersection = new IntersectionObserver((entries) => {
248
251
  const entry = entries[entries.length - 1]
249
- if (entry && entry.intersectionRatio === 0) this.blur()
252
+ if (!entry) return
253
+ if (!intersectionInitialised) {
254
+ intersectionInitialised = true
255
+ return
256
+ }
257
+ if (entry.intersectionRatio === 0) this.blur()
250
258
  }, { threshold: 0 })
251
259
  this._anchorIntersection.observe(anchor)
252
260
  }
@@ -261,10 +269,15 @@ export default {
261
269
  }
262
270
  window.removeEventListener('scroll', this._onScroll, true)
263
271
  window.removeEventListener('resize', this._onResize)
264
- if (this._onViewportChange && window.visualViewport) {
265
- window.visualViewport.removeEventListener('resize', this._onViewportChange)
266
- window.visualViewport.removeEventListener('scroll', this._onViewportChange)
267
- this._onViewportChange = null
272
+ if (window.visualViewport) {
273
+ if (this._onViewportScroll) {
274
+ window.visualViewport.removeEventListener('scroll', this._onViewportScroll)
275
+ this._onViewportScroll = null
276
+ }
277
+ if (this._onViewportResize) {
278
+ window.visualViewport.removeEventListener('resize', this._onViewportResize)
279
+ this._onViewportResize = null
280
+ }
268
281
  }
269
282
  if (this._panelObserver) {
270
283
  this._panelObserver.disconnect()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-kompo-utils",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {