themyth92 / ngx-lightbox

Lightbox2 use with angular >= 5
MIT License
115 stars 70 forks source link

There is no way to stop event propagation #31

Open narekharutyunyan opened 5 years ago

narekharutyunyan commented 5 years ago

I've my lightbox control in modal dialog and when I press "Esc" it closes both lightbox and dialog.

I would be great if you can extend this._lightboxEvent.broadcastLightboxEvent method to pass $event as well (this._lightboxEvent.broadcastLightboxEvent({..., $event: $event})) so preventDefault() can be called from client side.

ightboxComponent.prototype._keyboardAction = function ($event) {
        var KEYCODE_ESC = 27;
        var KEYCODE_LEFTARROW = 37;
        var KEYCODE_RIGHTARROW = 39;
        var keycode = $event.keyCode;
        var key = String.fromCharCode(keycode).toLowerCase();
        if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
            this._lightboxEvent.broadcastLightboxEvent({ id: lightbox_event_service_1.LIGHTBOX_EVENT.CLOSE, data: null });
tomwillwerth commented 5 years ago

Hi, I'm encountering the same behavior - open lightbox from a modal dialog and ESC closes both lightbox and the dialog.

A method to stop the event propagation would be great - maybe pass the vent as suggested, or a new option.

unxed commented 4 years ago

I'm working it around by checking if lightbox is open in my dialog close code and ignoring ESC if so.

emilianobaldo commented 1 year ago

Hi, no updates about this?