How to use @cycjimmy/awesome-js-funcs - 10 common examples

To help you get started, we’ve selected a few @cycjimmy/awesome-js-funcs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cycjimmy / h5-webpack-starter / app / load.js View on Github external
// services
import preventDefault from '@cycjimmy/awesome-js-funcs/event/preventDefault';

// polyfill
import './polyfill';

// offline runtime
if (!DEVELOPMENT) {
  const OfflinePluginRuntime = require('offline-plugin/runtime');
  OfflinePluginRuntime.install();
}

if (DEVELOPMENT) {
  console.log('Development Mode');
  console.log(require('@cycjimmy/awesome-js-funcs/handheld').getBrowserInfo());
}

if (PRODUCTION) {
  console.log('Production Mode');
}

// contextMenu preventDefault
document.addEventListener('contextmenu', preventDefault);

// fix ios native scrolling
document.body.addEventListener('touchmove', preventDefault, {passive: false});

// component
import LoadingComponent from './loadingComponent/Loading.component';
import PromptMobileComponentIns from './share/promptMobile/PromptMobile.component.ins';
github cycjimmy / swiper-animation / src / index.js View on Github external
_initAllBoxes() {
    if (this.allBoxes.length) {
      return Promise.resolve();
    }

    return functionToPromise(() => {
      let swiperWrapper = null;

      if (this.swiper.wrapperEl) {
        // swiper 4+
        swiperWrapper = this.swiper.wrapperEl;
      } else if (this.swiper.wrapper) {
        // swiper 3.x
        swiperWrapper = this.swiper.wrapper[0];
      }

      this.allBoxes = [
        ...nodeListToArray(swiperWrapper.querySelectorAll('[data-swiper-animation]')),
        ...nodeListToArray(swiperWrapper.querySelectorAll('[data-swiper-animation-once]'))
      ];
    });
  }
github cycjimmy / jsmpeg-player / src / lib / video-element.js View on Github external
pause: () => {
        },
        stop: () => {
        },
        load: () => {
        },
      }, hooks),
    }, overlayOptions);

    this.options.needPlayButton = this.options.control && !this.options.picMode;

    this.player = null;

    // Setup canvas and play button
    this.els = {
      wrapper: isString(wrapper)
        ? document.querySelector(wrapper)
        : wrapper,
      canvas: null,
      playButton: document.createElement('div'),
      unmuteButton: null,
      poster: null,
    };

    if (window.getComputedStyle(this.els.wrapper).getPropertyValue('position') === 'static') {
      this.els.wrapper.style.position = 'relative';
    }

    this.els.wrapper.clientRect = this.els.wrapper.getBoundingClientRect();

    this.initCanvas();
    this.initPlayButton();
github cycjimmy / h5-video-player / src / index.js View on Github external
setTimeout(() => {
          const
            wrapperWidth = Number.parseInt(this.els.wrapper.style.width)
            , wrapperHeight = Number.parseInt(this.els.wrapper.style.height)
            , preComputedHeight = wrapperWidth / this.options.aspectRatio
          ;

          if (preComputedHeight >= wrapperHeight) { // based on wrapperWidth
            addStyles(this.els.videoWrapperForConstraintRatio, {
              width: wrapperWidth + 'px',
              height: preComputedHeight + 'px',
            });
          } else {  // based on wrapperHeight
            addStyles(this.els.videoWrapperForConstraintRatio, {
              width: wrapperHeight * this.options.aspectRatio + 'px',
              height: wrapperHeight + 'px',
            });
          }
        }, 0);
      }
github cycjimmy / h5-video-player / src / index.js View on Github external
, _changeStyle = () => {
        const
          containerRectWidth = containerRect().width
          , containerRectHeight = containerRect().height
        ;

        if (_judgePhoneOrientation() === this.options.orientation) {
          addStyles(this.els.wrapper, {
            width: containerRectWidth + 'px',
            height: containerRectHeight + 'px',
            transform: '',
          });
        } else {
          // Adjust the video orientation
          addStyles(this.els.wrapper, {
            width: containerRectHeight + 'px',
            height: containerRectWidth + 'px',
            transform: 'rotate(-90deg)',
          });
        }

        // set videoWrapperForConstraintRatio width&height
        setTimeout(() => {
          const
github cycjimmy / h5-webpack-starter / app / share / promptMobile / PromptMobile.component.ins.js View on Github external
// constructor
import CreateInstance from '@cycjimmy/awesome-js-funcs/designPattern/CreateInstance';

import isMobile from '@cycjimmy/awesome-js-funcs/handheld/isMobile';

import promptMobile from './promptMobile.pug'
import _style from './promptMobile.scss'

// image
import QRCodeImg from '../../../static/images/QRCode.png';

const _createInstance = new CreateInstance();    // 构造函数实例

export default class PromptMobileComponentIns {
  constructor() {
    if (_createInstance()) {
      return _createInstance();
    }
    this.isMobile = false;
    this.wrapper = document.createElement('div');

    _createInstance(this);
  };

  load() {
    return new Promise((resolve, reject) => {
      if (isMobile()) {
        this.isMobile = true;
github cycjimmy / h5-webpack-starter / app / mainComponent / jsmpegDemo / jsmpegDemo.component.ins.js View on Github external
paramInit() {
    this.oVideoWrapper = this.context.querySelector('.' + _style.videoWrapper);
    this.aVideoChooseBtns = nodeListToArray(this.context.querySelectorAll('.' + _style.videoChoose));
  };
github cycjimmy / h5-webpack-starter / app / loadingComponent / Loading.component.js View on Github external
render() {
    return functionToPromise(() => {
      this.context.innerHTML = templateLoading({_style, imgLoading});
      document.body.appendChild(this.context);
    });
  };
github cycjimmy / h5-webpack-starter / app / share / promptOrientation / PromptOrientation.component.ins.js View on Github external
load() {
    return functionToPromise(() => {
      this.wrapper.innerHTML = promptOrientation({
        _style,
        suggest: 'Turn to portrait for better experience.',
      });
    }).then(() => {
      document.body.appendChild(this.wrapper);
    });
  };
github cycjimmy / h5-webpack-starter / app / share / Component / index.js View on Github external
render({
           pugTemplate,
           wrapperElement,
           insetParam,
           isAddToEl = false,
         }) {
    return functionToPromise(() => new Templates(pugTemplate, wrapperElement, insetParam).load(isAddToEl));
  };