A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/commit/064cdf4f7e7c6b779c1bd689a6d300efdf81bc0d below:

ensure all intervals/timeouts/observers are cleared when compone… · bootstrap-vue/bootstrap-vue@064cdf4 · GitHub

@@ -205,9 +205,10 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({

205 205

},

206 206

created() {

207 207

// Create private non-reactive props

208 -

this._intervalId = null

209 -

this._animationTimeout = null

210 -

this._touchTimeout = null

208 +

this.$_interval = null

209 +

this.$_animationTimeout = null

210 +

this.$_touchTimeout = null

211 +

this.$_observer = null

211 212

// Set initial paused state

212 213

this.isPaused = !(toInteger(this.interval, 0) > 0)

213 214

},

@@ -217,22 +218,39 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({

217 218

// Get all slides

218 219

this.updateSlides()

219 220

// Observe child changes so we can update slide list

220 -

observeDom(this.$refs.inner, this.updateSlides.bind(this), {

221 -

subtree: false,

222 -

childList: true,

223 -

attributes: true,

224 -

attributeFilter: ['id']

225 -

})

221 +

this.setObserver(true)

226 222

},

227 223

beforeDestroy() {

228 -

clearTimeout(this._animationTimeout)

229 -

clearTimeout(this._touchTimeout)

230 -

clearInterval(this._intervalId)

231 -

this._intervalId = null

232 -

this._animationTimeout = null

233 -

this._touchTimeout = null

224 +

this.clearInterval()

225 +

this.clearAnimationTimeout()

226 +

this.clearTouchTimeout()

227 +

this.setObserver(false)

234 228

},

235 229

methods: {

230 +

clearInterval() {

231 +

clearInterval(this.$_interval)

232 +

this.$_interval = null

233 +

},

234 +

clearAnimationTimeout() {

235 +

clearTimeout(this.$_animationTimeout)

236 +

this.$_animationTimeout = null

237 +

},

238 +

clearTouchTimeout() {

239 +

clearTimeout(this.$_touchTimeout)

240 +

this.$_touchTimeout = null

241 +

},

242 +

setObserver(on = false) {

243 +

this.$_observer && this.$_observer.disconnect()

244 +

this.$_observer = null

245 +

if (on) {

246 +

this.$_observer = observeDom(this.$refs.inner, this.updateSlides.bind(this), {

247 +

subtree: false,

248 +

childList: true,

249 +

attributes: true,

250 +

attributeFilter: ['id']

251 +

})

252 +

}

253 +

},

236 254

// Set slide

237 255

setSlide(slide, direction = null) {

238 256

// Don't animate when page is not visible

@@ -286,24 +304,18 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({

286 304

if (!evt) {

287 305

this.isPaused = true

288 306

}

289 -

if (this._intervalId) {

290 -

clearInterval(this._intervalId)

291 -

this._intervalId = null

292 -

}

307 +

this.clearInterval()

293 308

},

294 309

// Start auto rotate slides

295 310

start(evt) {

296 311

if (!evt) {

297 312

this.isPaused = false

298 313

}

299 314

/* istanbul ignore next: most likely will never happen, but just in case */

300 -

if (this._intervalId) {

301 -

clearInterval(this._intervalId)

302 -

this._intervalId = null

303 -

}

315 +

this.clearInterval()

304 316

// Don't start if no interval, or less than 2 slides

305 317

if (this.interval && this.numSlides > 1) {

306 -

this._intervalId = setInterval(this.next, mathMax(1000, this.interval))

318 +

this.$_interval = setInterval(this.next, mathMax(1000, this.interval))

307 319

}

308 320

},

309 321

// Restart auto rotate slides when focus/hover leaves the carousel

@@ -362,7 +374,7 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({

362 374

eventOff(currentSlide, evt, onceTransEnd, EVENT_OPTIONS_NO_CAPTURE)

363 375

)

364 376

}

365 -

this._animationTimeout = null

377 +

this.clearAnimationTimeout()

366 378

removeClass(nextSlide, dirClass)

367 379

removeClass(nextSlide, overlayClass)

368 380

addClass(nextSlide, 'active')

@@ -387,7 +399,7 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({

387 399

)

388 400

}

389 401

// Fallback to setTimeout()

390 -

this._animationTimeout = setTimeout(onceTransEnd, TRANS_DURATION)

402 +

this.$_animationTimeout = setTimeout(onceTransEnd, TRANS_DURATION)

391 403

}

392 404

if (isCycling) {

393 405

this.start(false)

@@ -480,10 +492,8 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({

480 492

// is NOT fired) and after a timeout (to allow for mouse compatibility

481 493

// events to fire) we explicitly restart cycling

482 494

this.pause(false)

483 -

if (this._touchTimeout) {

484 -

clearTimeout(this._touchTimeout)

485 -

}

486 -

this._touchTimeout = setTimeout(

495 +

this.clearTouchTimeout()

496 +

this.$_touchTimeout = setTimeout(

487 497

this.start,

488 498

TOUCH_EVENT_COMPAT_WAIT + mathMax(1000, this.interval)

489 499

)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4