Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing onClick event on Image to do in example "next() #143

Open
scco opened this issue Dec 16, 2023 · 2 comments
Open

missing onClick event on Image to do in example "next() #143

scco opened this issue Dec 16, 2023 · 2 comments
Labels
feature request feature request

Comments

@scco
Copy link

scco commented Dec 16, 2023

how to have @click="next()" feature on each lightbox element.

as i can not acces / style the img itself via slots, i suggest to have a slot for the content itself .

pseudo-code :

    <template v-slot:content="{ index }">
      <img
        :src="lightboxImages[index].src"
        :alt="lightboxImages[index].title"
        @click="showNextImage"
      />
    </template> 

or please add a new pro like

:onClickNextImage = enabled

if there is a simple way how i could achive the same in a simpler way , please let me know

@XiongAmao XiongAmao added the feature request feature request label Dec 23, 2023
@XiongAmao
Copy link
Owner

I've reread my code.
It seems difficult to add click handler to multiple gesture events.

const renderImgWrapper = () => {
return (
<div
class={`${prefixCls}-img-wrapper`}
style={imgWrapperStyle.value}
key="img-wrapper"
>
<img
alt={currentImgAlt.value}
ref={imgRef}
draggable="false"
class={`${prefixCls}-img`}
src={currentImgSrc.value}
onMousedown={onMouseDown}
onMouseup={onMouseUp}
onMousemove={onMouseMove}
onTouchstart={onTouchStart}
onTouchmove={onTouchMove}
onTouchend={onTouchEnd}
onLoad={onImgLoad}
onDblclick={onDblclick}
onDragstart={(e) => {
e.preventDefault()
}}
/>
</div>
)
}

I also used different <img /> for loading / error states. So <slot /> may not work.
I'll see if there's any other way to implement it.

@scco
Copy link
Author

scco commented Jan 10, 2024

do you try to do this without any dependencies ? it might get truly hard to do event coordination, gesture recognition, handling clicks and swipes together, and tweaking sensitivity / tresholds ...

maybe Hammer.js could help to simplify the handling of touch and mouse events.
it provides a unified API for handling various input types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request
Projects
None yet
Development

No branches or pull requests

2 participants