Giter VIP home page Giter VIP logo

vue's Introduction

@twicpics/vue

npm version npm downloads License

TwicPics integration with Vue.js. This library is also available as a NuxtJS module.


โš ๏ธ Deprecation warning โš ๏ธ

This package has been deprecated in favor of TwicPics Components.

TwicPics Components is a collection of web components that make it dead easy to unleash the power of TwicPics in your own projects and using the framework of your choice.

๐Ÿ‘‰ Check the documentation


Setup

  1. Add @twicpics/vue dependency to your project
yarn add @twicpics/vue
# or npm install @twicpics/vue
  1. Import components
import Vue from "vue";
import VueTwicpics from "@twicpics/vue";
import "@twicpics/vue/dist/vuetwicpics.css";

Vue.use(VueTwicpics, {
  // Your TwicPics custom 
  domain: "https://sub-domain.twic.pics",
  // Optional settings
  defaultParams: {
    ...
  }
});

Options

domain (required)

This is your very own TwicPics domain.

defaultParams (optional)

anticipation

  • Default value: 0.2 (any value that is not a number will be ignored)

TwicPics will lazy-load images by default. To avoid too abrupt a transition with elements appearing into view and then images very obviously loading afterwards, TwicPics will "anticipate" lazy loading by a factor of the actual viewport. This behavior is controlled by this setting.

maxDpr

  • Default value: 2 (any value that is not a number will be ignored)

TwicPics will take the Device Pixel Ratio of the current device into consideration when determining the sizes of images to load. By default, it will not take a DPR greater than 2 into consideration. If the DPR of the device is higher than 2, TwicPics will assume it to be 2. So you can lower it to 1 or be more permissive (for instance by setting it to 3 or 4).

step

  • Default value: 10 (any value that is not a number will be ignored)

To avoid requesting too may variants of the same image, TwicPics will round the width of images to the closest multiple of step. The height will then be computed in order to respect the original aspect ratio.

Usage

TwicImg component

<twic-img src="<image-path>"
          width="<integer>"
          height="<integer>"
          placeholder="<none|preview|meancolor|maincolor>"
          ratio="<ratio>"
          step="<integer>"
          focus="<auto|coordinates>"
          transition="<boolean>" />
Name Description Type Default Required
src Absolute or relative path to an image. String true
width See ratio. Integer false
height See ratio. Integer false
ratio Unitless width/height values. You can either use ratio or width and height to set the aspect-ratio of your image. If both are used, ratio win. A squared image will be rendered by default. String 1/1 false
placeholder Can be preview, meancolor, maincolor or none. String preview false
step See TwicPics documentation for details. Integer 10 false
focus Can be auto or coordinates - see TwicPics documentation for details. String 10 false
transition Whether or not to load images with a fade in effect. Boolean true false
transitionDuration Duration of the transition effect. String 400ms false
transitionTimingFunction CSS timing function applied to the transition effect. String ease false
transitionDelay Transition delay of the transition effect. String 0ms false
alt Alt attribute content String Image name without extention false

Example

<template>
  <main>
    <twic-img
      src="/my-image.jpg"
      ratio="16/9"
      step="100"
      placeholder="preview"
      alt="my image" />
  </main>
</template>

<script>
export default {

}
</script>

Demo

Edit TwicPics Vue

NuxtJS

This library is also available as a NuxtJS module.

License

MIT License

Copyright (c) TwicPics

vue's People

Contributors

florentb avatar szatee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

studiometa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.