lukeed / bee3d

Support Forum for Bee3D Slider, found @ http://www.lukeed.com/demo/bee3D
MIT License
7 stars 2 forks source link

I need to re-initiate the slider after filteration #70

Closed alfarqi closed 6 years ago

alfarqi commented 6 years ago

Hi, i need to call a function that can re-initiate the slider again, because i am using the slider code with div filtration to show and hide some results of bee3d item....so after hiding some elements... i will need to call a bee3d function again to re-arrange the slider numbers.....for example in the beginning 10 items will be loaded ...by using div filter to show or hide elements based on some user selections...the slider items will shrink to 5 items....so i will need again to readjust the 5 items....so how i can do that?

lukeed commented 6 years ago

Hi there!

You can just recreate the slider instance repeatedly. Most of the logic you need will happen within your filtering function --- Bee3D does not do any of this for you, and ONLY manages classnames on each slide element.

Also, since you're hiding elements, it sounds like you might want/need to track the active slide index, so that when someone is on Slide#9, then filters down to 5, they aren't forced back to Slide#0... right? Again, Bee3D can't do that for you, but you can easily calculate this within your own logic (since it's custom anyway) and then supply the new Bee3D instance a new options.focus value.

var elem = document.getElementById('slider');
var config = {
  // ... all your initial options
};

// first init
var slider = new Bee3D(elem, config);

// do filtering...

// grab the currently-active slide
let idx = slider.el.slide();

// set new focus for new slider
config.focus = 8; // <~ made up value

// re-init
slider = new Bee3D(elem, config);

Your other option, which is probably more feasible, is to apply a new classname on the items you've marked as hidden. For example, you add a "hidden" class to all slides that have been filtered away.

Then, the important part: You have to (greatly) modify the CSS classnames.

Instead of relying on .bee3D--{EFFECT} .bee3D--after-{INDEX}, you'd use .bee3D--{EFFECT} .bee3D--after:nth-child({INDEX}). Basically, use :nth-child() operator on all --before + --after classes instead of relying on Bee3D's --before-X + --after-Y counting.

Finally, you'd have to also use the :not() CSS operator to ignore the "hidden" classname you decide to use.

For example:

.bee3D--effect__arc 
  .bee3D--after
    transform: translateX(750px) translateY(240px) rotateZ(17deg) scale(0.5)
    opacity: 0

    // previously 'after-1'
    &:not(.hidden):nth-child(0) 
      transform: translateX(350px) translateY(75px) rotateZ(8deg) scale(0.8)
      opacity: 0.5

    // previously 'after-2'
    &:not(.hidden):nth-child(1)
      transform: translateX(560px) translateY(160px) rotateZ(14deg) scale(0.6)
      opacity: 0.3

    // etc

This approach is likely your best option because Bee3D still counts (aka, adds -1, -2, ..etc) all slides within the parent slider. Because of this, the first option would need to create & destroy slide elements during your filter, while also keeping track of original indexing.

Hope that helps!

alfarqi commented 6 years ago

Hi, Thanks for you response but unfortunately i couldn't make it, and still trying to find a solution...i have tried both ways but no luck:

this is the website that i am working on http://janxcode.com/king/index2.html for video filter based on year....

by using jquery i have done the following:

  1. once the year is selected the other slides will be hidden and moved into another div so that will not effect the sliding numbers, but lately i have figured out that still the counter counts the whole number of slides. not only the 2 or 3 existing slides under active bee-3d slider.

  2. your first way, helped me a little but still the slider counting the total initial number of slides....i need to reset that after removing the unmatched slides

  3. i also tried using the 2nd way but also that have an issue, i couldn't detect the first occur of bee-3d--after or bee-3d--before after the active class name....consider that if we used nth-child(2) for after class name,,but its not necessarily that is the 2nd div ..it might be the 4th div in the list....

please help me since i am still facing an issue with that and could not solve it....

lukeed commented 6 years ago

Hey, checked out the site -- looks cool!

I totally forgot that :not() does not work with :nth-of-type() -- disappointing! That would have worked perfectly for us.

Instead, I put together a quick demo for Option 1, showing how you'd easily update the classnames based on your selection. Unfortunately, you'd still have to edit the Bee3D code directly to manage future className updates; eg, whenever you swipe, scroll, or click a slide to update the active element.

This is because you're adding completely custom behavior that Bee3D does not support. I'm just guiding you towards what you want.

alfarqi commented 6 years ago

Hi, Thanks really for your inputs, my problem is after item has been filtered and items become from 10 to 5 items inside the bee---3d slider div....and the other are moved to external div and hidden....but still when i move the slider cursor...still the hidden slides are counted as a part of the filtered sliders and when i scroll left and right that class names also keep changing.....what i need , once i filtered the items and have 5 items inside the slider, then hidden slides should not effected with and not considered as a part of the filtered items...like that it counts altogether and then it will slide all together even the hidden item even its hidden

regards, farooq

On Sat, Jul 7, 2018 at 4:22 AM, Luke Edwards notifications@github.com wrote:

Hey, checked out the site -- looks cool!

I totally forgot that :not() does not work with :nth-of-type() -- disappointing! That would have worked perfectly for us.

Instead, I put together a quick demo https://jsfiddle.net/lukeed/czen04ds/ for Option 1, showing how you'd easily update the classnames based on your selection. Unfortunately, you'd still have to edit the Bee3D code directly to manage future className updates; eg, whenever you swipe, scroll, or click a slide to update the active element.

This is because you're adding completely custom behavior that Bee3D does not support. I'm just guiding you towards what you want.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukeed/bee3d/issues/70#issuecomment-403179156, or mute the thread https://github.com/notifications/unsubscribe-auth/AE92pIcyoTbzHVjcfmQSLhSpBO7eTwAkks5uEA08gaJpZM4VCHYv .

lukeed commented 6 years ago

Hey, no problem! Yes, this is what I meant by this part:

Unfortunately, you'd still have to edit the Bee3D code directly to manage future className updates; eg, whenever you swipe, scroll, or click a slide to update the active element. This is because you're adding completely custom behavior that Bee3D does not support. I'm just guiding you towards what you want.

You require custom behavior that isn't part of Bee3D -- so you will need to edit the JS directly to discount any hidden/filtered when navigating.

alfarqi commented 6 years ago

i need to remove all the div slides that pushed initially, by pushing new set of div to the sliders array....is there any method that u can help me with

On Mon, Jul 9, 2018 at 10:58 AM, Luke Edwards notifications@github.com wrote:

Hey, no problem! Yes, this is what I meant by this part:

Unfortunately, you'd still have to edit the Bee3D code directly to manage future className updates; eg, whenever you swipe, scroll, or click a slide to update the active element. This is because you're adding completely custom behavior that Bee3D does not support. I'm just guiding you towards what you want.

You require custom behavior that isn't part of Bee3D -- so you will need to edit the JS directly to discount any hidden/filtered when navigating.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukeed/bee3d/issues/70#issuecomment-403393041, or mute the thread https://github.com/notifications/unsubscribe-auth/AE92pL0gbOhOTaiHJHgS4VTnEDkaSfrhks5uEw0VgaJpZM4VCHYv .

lukeed commented 6 years ago

I thought of another way for you:

Using the CSS changes above that we talked about, you can then use Command Listeners to navigate away from slides that are hidden. For example:

slider.el.on('next', ev => {
  // if new slide is HIDDEN, call "next()" again
  if (ev.slide.classList.contains('HIDDEN')) slider.el.next();
});

slider.el.on('prev', ev => {
  // if new slide is HIDDEN, call "prev()" again
  if (ev.slide.classList.contains('HIDDEN')) slider.el.prev();
});
alfarqi commented 6 years ago

Great thanks ... will chk it by tommorrow... i am really struggling with this :(... really thanks for ur input

On Mon, 9 Jul 2018, 21:43 Luke Edwards, notifications@github.com wrote:

I thought of another way for you:

Using the CSS changes above that we talked about, you can then use Command Listeners https://github.com/lukeed/bee3d/wiki/Commands#command-listeners to navigate away from slides that are hidden. For example:

slider.el.on('next', ev => { // if new slide is HIDDEN, call "next()" again if (ev.slide.classList.contains('HIDDEN')) slider.el.next(); }); slider.el.on('prev', ev => { // if new slide is HIDDEN, call "prev()" again if (ev.slide.classList.contains('HIDDEN')) slider.el.prev(); });

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukeed/bee3d/issues/70#issuecomment-403580417, or mute the thread https://github.com/notifications/unsubscribe-auth/AE92pPVkATsnrfqfrfTmSarYLwscY-puks5uE6RBgaJpZM4VCHYv .

lukeed commented 6 years ago

Sorry to hear~! The above should definitely work for you though 🎉

alfarqi commented 6 years ago

thanks for your inputs,,,but doesnt solved anything ;(.....

On Mon, Jul 9, 2018 at 10:30 PM, Luke Edwards notifications@github.com wrote:

Sorry to hear~! The above should definitely work for you though 🎉

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukeed/bee3d/issues/70#issuecomment-403593911, or mute the thread https://github.com/notifications/unsubscribe-auth/AE92pBH6m_4vXDgRl9mSMHrvhi_ZhV-Cks5uE69VgaJpZM4VCHYv .

alfarqi commented 6 years ago

hi, sorry to bother you but i might get ur idea in this that can solve my issue.

here what i have done:

  1. on page load all items are shown normally on class-a
  2. by filtering the item by year e.g.2002---all instance tag items are moved to outside div and all are hidden, div called .king-hidden
  3. slider is destroyed here
  4. then from that div .king-hidden i will select all matching divs to 2002 will be moved to the old slider div
  5. initiate the slider again

seems work fine, but one issue i am facing,,,, if for example i have 3 divs under slider tag....the class names are after-1,before-1,after-2,after-1 are not added properly....i couldn't figure out that yet... you can test the updates on this link

http://janxcode.com/king/index2.html

...thanks

On Tue, Jul 10, 2018 at 11:32 AM, Farooq Abdul Aziz alfarqi@gmail.com wrote:

thanks for your inputs,,,but doesnt solved anything ;(.....

On Mon, Jul 9, 2018 at 10:30 PM, Luke Edwards notifications@github.com wrote:

Sorry to hear~! The above should definitely work for you though 🎉

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukeed/bee3d/issues/70#issuecomment-403593911, or mute the thread https://github.com/notifications/unsubscribe-auth/AE92pBH6m_4vXDgRl9mSMHrvhi_ZhV-Cks5uE69VgaJpZM4VCHYv .

alfarqi commented 6 years ago

Have u got any chance to test that ?

On Tue, Jul 10, 2018 at 1:49 PM, Farooq Abdul Aziz alfarqi@gmail.com wrote:

hi, sorry to bother you but i might get ur idea in this that can solve my issue.

here what i have done:

  1. on page load all items are shown normally on class-a
  2. by filtering the item by year e.g.2002---all instance tag items are moved to outside div and all are hidden, div called .king-hidden
  3. slider is destroyed here
  4. then from that div .king-hidden i will select all matching divs to 2002 will be moved to the old slider div
  5. initiate the slider again

seems work fine, but one issue i am facing,,,, if for example i have 3 divs under slider tag....the class names are after-1,before-1,after-2,after-1 are not added properly....i couldn't figure out that yet... you can test the updates on this link

http://janxcode.com/king/index2.html

...thanks

On Tue, Jul 10, 2018 at 11:32 AM, Farooq Abdul Aziz alfarqi@gmail.com wrote:

thanks for your inputs,,,but doesnt solved anything ;(.....

On Mon, Jul 9, 2018 at 10:30 PM, Luke Edwards notifications@github.com wrote:

Sorry to hear~! The above should definitely work for you though 🎉

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukeed/bee3d/issues/70#issuecomment-403593911, or mute the thread https://github.com/notifications/unsubscribe-auth/AE92pBH6m_4vXDgRl9mSMHrvhi_ZhV-Cks5uE69VgaJpZM4VCHYv .