Giter Site home page Giter Site logo

Comments (11)

daniel-jonathan avatar daniel-jonathan commented on May 8, 2024

Hey :)

That is a very specific use case. Preferably, I would like to keep the card more generic.

One way of doing it, could be to add a tap gesture on the card and see if the tap is within the bounds of the image frame, which you can access from the optional imageLayer property that is set when you add an image.

from material.

 avatar commented on May 8, 2024

Yeah I understand. That is a decent workaround, I'm using a UITapGestureRecognizer right now and it's still buggy as hell.

from material.

daniel-jonathan avatar daniel-jonathan commented on May 8, 2024

Actually, an even better approach would be to subclass the ImageCardView, which is a subclass of MaterialPulseView. Override the touchesBegan method, and if the touch is within the imageLayer execute your lightbox, if not, call the super.touchesBegan method.

from material.

daniel-jonathan avatar daniel-jonathan commented on May 8, 2024

public override func touchesBegan(touches: Set, withEvent event: UIEvent?) {

    let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
    if true == imageLayer?.containsPoint(point) {
        ...
    } else {
                  super.touchesBegan(touches, withEvent: event)
            }
}

I haven't tested the code, though this is the idea.

from material.

daniel-jonathan avatar daniel-jonathan commented on May 8, 2024

You can do the same with touchesEnd, which may be better to keep the pulse in general, though, you have to call super in that case to shrink the pulse.

from material.

 avatar commented on May 8, 2024

Ahh interesting idea. I'll experiment! Thanks :)

(btw It's me, @cohix, I used the wrong account by accident)

from material.

daniel-jonathan avatar daniel-jonathan commented on May 8, 2024

Awesome :) How are you liking MaterialKit? We are planning a really awesome update shortly.

from material.

 avatar commented on May 8, 2024

Liking it very much! I'm very happy with it so far

from material.

daniel-jonathan avatar daniel-jonathan commented on May 8, 2024

Great! Okay, after your experimentation, let us know how it worked out and close the ticket. All the best :)

from material.

 avatar commented on May 8, 2024

Will do! Cheers.

from material.

 avatar commented on May 8, 2024

I ended up using your solution, works quite well!

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?)
    {
        let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)

        if imageLayer!.containsPoint(point)
        {
            // Show ligntbox
        }

        super.touchesEnded(touches, withEvent: event)
    }

from material.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.