Sha256: 3daf4cbd86b19674ac3598a1acaf8b8148e5a87a6453cd29681c72ce2984a0d9

Contents?: true

Size: 494 Bytes

Versions: 13

Compression:

Stored size: 494 Bytes

Contents

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = [ "content" ]

  next() {
    this.contentTarget.scrollTo({ left: this.#scrollLeft + this.#slideSize, behavior: "smooth" })
  }

  previous() {
    this.contentTarget.scrollTo({ left: this.#scrollLeft - this.#slideSize, behavior: "smooth" })
  }

  get #scrollLeft() {
    return this.contentTarget.scrollLeft
  }

  get #slideSize() {
    return this.contentTarget.clientWidth
  }
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
css-zero-0.0.35 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.34 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.33 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.32 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.31 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.30 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.29 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.28 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.27 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.26 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.25 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.24 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js
css-zero-0.0.23 lib/generators/css_zero/add/templates/app/javascript/controllers/carousel_controller.js