How to use the cropperjs/src function in cropperjs

To help you get started, we’ve selected a few cropperjs 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 fengyuanchen / cropper / src / index.js View on Github external
this.each((i, element) => {
      const $element = $(element);
      const isDestroy = option === 'destroy';
      let cropper = $element.data(NAMESPACE);

      if (!cropper) {
        if (isDestroy) {
          return;
        }

        const options = $.extend({}, $element.data(), $.isPlainObject(option) && option);

        cropper = new Cropper(element, options);
        $element.data(NAMESPACE, cropper);
      }

      if (typeof option === 'string') {
        const fn = cropper[option];

        if ($.isFunction(fn)) {
          result = fn.apply(cropper, args);

          if (result === cropper) {
            result = undefined;
          }

          if (isDestroy) {
            $element.removeData(NAMESPACE);
          }
github netgen / NetgenRemoteMediaBundle / frontend / src / components / Crop.vue View on Github external
setCropper() {
      const { x, y, w, h } = this.value || {},
        data = { x, y, width: w, height: h },
        [variationWidth, variationHeight] = this.variation,
        aspectRatio =
          variationWidth > 0 && variationHeight > 0
            ? variationWidth / variationHeight
            : undefined;

      this.destroyCropper();

      const scale = this.$refs.cropper.clientWidth / this.imageSize.width;

      this.cropper = new Cropper(this.$refs.image, {
        viewMode: 2,
        dragMode: "none",
        autoCrop: true,
        data,
        aspectRatio,
        guides: true,
        movable: false,
        rotatable: false,
        guides: false,
        center: false,
        zoomable: false,
        scalable: true,
        minCropBoxWidth: 50,
        minCropBoxHeight: 50,
        crop: this.handleCrop,
        preview: this.$refs.preview

cropperjs

JavaScript image cropper.

MIT
Latest version published 13 days ago

Package Health Score

91 / 100
Full package analysis