Sha256: 9ac95460574843b28b32380b65cbd7a5eab1162824e9902d3092f148571c0087

Contents?: true

Size: 488 Bytes

Versions: 159

Compression:

Stored size: 488 Bytes

Contents

import { Controller } from '@hotwired/stimulus'

// To be used by img_placeholder helper
export default class extends Controller {
  connect () {
    if (this.element.complete) {
      this.loaded()
    } else {
      this.element.addEventListener('load', () => {
        this.loaded()
      }, { once: true })
    }
  }

  loaded () {
    this.element.classList.add('fade-in')
    this.element.style.display = 'block'
    this.element.parentElement.classList.remove('placeholder')
  }
}

Version data entries

159 entries across 159 versions & 1 rubygems

Version Path
pg_rails-7.6.27 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.26 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.25 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.24 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.24.pre.5 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.24.pre.4 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.24.pre.3 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.23 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.22 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.22.pre.3 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.22.pre.2 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.22.pre.1 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.11 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.10 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.9 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.8 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.7 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.6 pg_layout/app/javascript/controllers/fadein_onload_controller.js
pg_rails-7.6.21.pre.5 pg_layout/app/javascript/controllers/fadein_onload_controller.js