1.0.3 • Published 7 months ago

@itkyk/preload v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

Preloader

install

npm i @itkyk/preload

How to use?

Import this Module

import * as Preload from "@itkyk/preload";
// OR
import {Image, Video} from "@itkyk/preload";

Use Video Preload

// HTML
<video class="js-preload-video" src="" data-video-path="/video/to/path/hoge.mp4" />
new Preload.Video(".js-preload-video", (status, loadedFiles, total) => {
  console.log(status, loadedFiles, total); // complete, ["/video/to/path/hoge.mp4"] 1;
});

Use Image Preload

const fileNameArray = ["/img/to/path/hoge.jpg","/img/to/path/fuga.jpg"];
const imagePreload = new Preload.Image(fileNameArray, (status, loadedFiles, total) => {
  console.log(status, loadedFiles, total); // loading ["/img/to/path/hoge.jpg"] 2;
});

Params

VideoPreloader

argumenttypedescription
attributestringターゲットとするクラス名を指定
callbackfunction各ファイルが読み込まれた時に実行

ImagePreloader

argumenttypedefaultdescription
filePathArrayArraynullプリロードしたい画像のパスを指定(配列で複数指定可)
callbackfunctionnull各ファイルが読み込まれた時に実行
1.0.3

7 months ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago