fancyapps / ui

A library of JavaScript UI components, includes the best lightbox - Fancybox5
https://fancyapps.com/
Other
785 stars 98 forks source link

Fancybox protect option no longer exist in v4.0 #351

Closed n-rodriguez closed 1 year ago

n-rodriguez commented 2 years ago

Before : https://github.com/fancyapps/fancybox/search?q=protect After : https://github.com/fancyapps/ui/search?q=protect

The feature : https://github.com/fancyapps/fancybox/blob/c4fd90370f8c93336d6e36a5c6120bcabcf8675c/docs/index.html#L579-L582

To resume: with Fancybox v4 you can right click and download images even if the protect option is true. (of course, the feature no longer exists...)

n-rodriguez commented 2 years ago

I'm was able to workaround this with :

    window.Fancybox.bind '[data-fancybox]',
      on:
        load: (fancybox, slide) =>
          $(slide.$content).on "contextmenu.fb", (e) ->
            if e.button == 2
              e.preventDefault()
            return true

but the "missing feature" issue it's pretty unexpected.

oliversmiths commented 1 year ago

I wonder if anyone can help further, have tried @n-rodriguez solution but could not get to work.

fancyapps commented 1 year ago

@oliversmiths Here is an example:

Fancybox.bind('[data-fancybox]', {
  on: {
    load: (fancybox, slide) => {
      slide.$content.addEventListener("contextmenu", (e) => {
        e.preventDefault()
      });
    }
  }
});
oliversmiths commented 1 year ago

Many thanks – works perfectly

SamuelGaona commented 1 year ago

I used a css class:

// Prevent fancybox images download
.fancybox__container img
  pointer-events: none
fancyapps commented 1 year ago

Hi, protected option is now available in v5, use it like this:

Fancybox.bind('[data-fancybox="gallery"]', {
  Images : {
    protected: true
  }
});  

https://jsfiddle.net/vaqhwy1L/

n-rodriguez commented 1 year ago

Hi, protected option is now available in v5, use it like this:

Thank you!