glide icon indicating copy to clipboard operation
glide copied to clipboard

Peak + Bound

Open oleh-khalin opened this issue 6 years ago • 2 comments

I can't understand how to delete peak (left margin) in slider mode with bound. I just don't need to show the free space after last item. image

oleh-khalin avatar Jun 29 '19 13:06 oleh-khalin

I made a custom transformer to remove peek from last item with 'bound' option. Feel free to use it!

var FixBoundPeek = function (Glide, Components, Events) {
  return {
    /**
     * Fix peek 'after' with 'bound' option.
     *
     * @param  {Number} translate
     * @return {Number}
     */
    modify (translate) {
      var isBound = Components.Run.isBound
      // future method from 'master'
      if (typeof isBound !== 'function') {
        isBound = function () {
          return Glide.isType('slider') && Glide.settings.focusAt !== 'center' && Glide.settings.bound
        }
      }

      if (isBound() && Components.Run.isEnd()) {
        const peek = Components.Peek.value

        if (typeof peek === 'object' && peek.after) {
          return translate - peek.after
        }

        return translate - peek
      }

      return translate
    }
  }
}

new Glide('.glide')
  .mutate([FixBoundPeek])
  .mount()

Djules avatar Feb 27 '20 00:02 Djules

@Djules thanks for this, this worked perfectly!

titchimoto avatar Feb 19 '21 16:02 titchimoto