How to use the @cycjimmy/awesome-js-funcs/dom/addStyles function in @cycjimmy/awesome-js-funcs

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-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-video-player / src / index.js View on Github external
, _changeOrientation = () => {
        window.removeEventListener(_orientationchangeEvt, _changeOrientation);

        setTimeout(() => {
          _changeStyle();
          window.addEventListener(_orientationchangeEvt, _changeOrientation, false);
        }, 400);
      }
    ;

    if (this.options.disableRotation) {
      _changeStyle();
      window.addEventListener(_orientationchangeEvt, _changeOrientation, false);

    } else {
      addStyles(this.els.wrapper, {
        width: containerRect().width + 'px',
        height: containerRect().height + 'px',
      });
    }
  };
}