question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

beforeChange (and afterChange) bubble

See original GitHub issue

http://jsfiddle.net/L1c949zf/1/

In the following setup, where each slide of .slider contains its own .sub-slider, currentSlide is logged to the console whenever either slider changes.

$(".slider").slick({
    autoplay: true,
    autoplaySpeed: 4000,
    dots: true
});

$(".sub-slider").slick({
    autoplay: true,
    autoplaySpeed: 1000,
    dots: false,
    arrows: false
});

$(".slider").on('beforeChange', function(event, slick, currentSlide) {
    console.log(currentSlide);
});

The only way I can think, currently, to ensure that it’s the .slider element that has changed is something like

$(".slider").on('beforeChange', function(event, slick, currentSlide) {
    if ($(slick.$slider).hasClass('slider')) {
        console.log(currentSlide);
    }
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kenwheelercommented, Jan 17, 2016

You can also cancel the bubble in a listener on the sub slider

1reaction
kenwheelercommented, Jan 17, 2016

You can check the target to differentiate

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slick carousel Slider Syncing beforechange/afterchange ...
I want the carousel to do some functions on afterchange & beforechange callbacks. The problem is that I don't want those functions to...
Read more >
slick carousel current slide after change Code Example
$('.your-element').on('beforeChange', function(event, slick, currentSlide, nextSlide){. 2. console.log(nextSlide);. 3. }); Source: kenwheeler.github.io.
Read more >
HTMLElement: change event - Web APIs | MDN
The change event is fired for , , and elements when the user modifies the element's value. Unlike the input event, the change...
Read more >
Autobinding sumproduct - Database - Bubble Forum
Sounds like you can use a database trigger with a strict contraints of “Product's price before change is not product's price after change”...
Read more >
#4 Slick callback + адаптивность / afterChange,beforeChange,init ...
#4 Slick callback + адаптивность / afterChange,beforeChange,init, responsive... 208 views208 views ... Bubble Responsive Design Crash Course. Matt Neary.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found