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.

Get item on beforeChange and afterChange events

See original GitHub issue

How can I get the item from the slide if either the beforeChange or afterChange event is fired?

So rather than:

pswp.listen('afterChange', function() { });

It be:

pswp.listen('afterChange', function($item) { });

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
dimsemenovcommented, Jul 21, 2015

pswp.currItem

1reaction
mastefcommented, Feb 23, 2018

Note : beforeChange gives you the indexDifference as first parameter.

So if you just opened the gallery, it will be null. If you went from 0 -> 1, it will be 1. You can get the previous index with :

         pswp.listen('beforeChange', function(indexDiff) {
                  var previousItem = (pswp.getCurrentIndex() - indexDiff);
         });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting value of select (dropdown) before change
I am using 1.3.2 version of jQuery and using on change event but the value I am getting over there is after change....
Read more >
MaskProperties.AfterChange Event | WinForms Controls
Occurs after a setting of the current MaskProperties object has been changed. Namespace: DevExpress.XtraEditors.Mask. Assembly: DevExpress.
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 >
Validation beforeChange AfterChange avoid indefinite loops
I'm designing a table and I'm stuck with the design functionality regarding the Validation, before change and after change events to avoid the...
Read more >
listening-proxy - npm
A Javascript deep proxy that can have listeners added (an event listener ... beforeChange and afterChange events; getProperty events - allow ...
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