javascript - Owl Carousel 2 - how to get a current item? -


i working on web site owl carousel 2. want detect item displayed on front.

it used this. http://owlgraphic.com/owlcarousel/demos/owlstatus.html

$(document).ready(function() {    var owl = $("#owl-demo"),       status = $("#owlstatus");    owl.owlcarousel({     navigation : true,     afteraction : afteraction   });    function updateresult(pos,value){     status.find(pos).find(".result").text(value);   }    function afteraction(){     updateresult(".currentitem", this.owl.currentitem);   } }); 

but example of version 1. in version 2, above doesn't work, , seems should use "info" according official document. http://owlcarousel.owlgraphic.com/docs/api-options.html#info

i tried figure out it, there no example or documents. went through .js file, couldn't it. wonder if "info" not implemented yet.

i don't want know info, want data of current item.

i tried way below, doesn't work correctly. have possible solutions?

var active = $("#owl-demo").find(".owl-item.active"); console.log(active.text()); 

i not leave here without answering. this. not find in docs too. dived spagetti code.

owl.on('changed.owl.carousel', function (e) {     console.log("current: ",e.relatedtarget.current())     console.log("current: ",e.item.index) //same     console.log("total: ",e.item.count)   //total }) 

more info: if want events trigger initial state. should add them before initialising owl. this.

var owl = $("#youritem") owl.on('changed.owl.carousel', function (e) {     console.log("current: ",e.relatedtarget.current())     console.log("current: ",e.item.index) //same     console.log("total: ",e.item.count)   //total }) // init owl.owlcarousel({settings}) 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -