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

Override Switch and useSwitch #22

Open
christophevouillamoz opened this issue Oct 11, 2021 · 0 comments
Open

Override Switch and useSwitch #22

christophevouillamoz opened this issue Oct 11, 2021 · 0 comments

Comments

@christophevouillamoz
Copy link

In Framer it is not possible to add an override as soon useSwitch is used. In the override panel the file is not selected anymore and it is not in the dropdown.

Bildschirmfoto 2021-10-11 um 11 29 05

Without the const controls = useSwitch() line of code, it works and you can choose the override as expected in the panel.

Bildschirmfoto 2021-10-11 um 11 31 26

I also tried to import the switch package from the import wizard but this will not work, no import button available.

Bildschirmfoto 2021-10-11 um 11 32 13

The Code

import { Override } from "framer"
import { useSwitch } from "@framer/tishogeorgiev.switch/code"

export function SwitchSwiper(): Override {
const controls = useSwitch()
var startPointX = 0

function onPanStart(event, info) {
    console.log("PanStart", info.point.x, info.point.y)
    startPointX = info.point.x
}

function onPanEnd(event, info) {
    console.log("PanEnd", info.point.x, info.point.y)

    var startPointDelta = info.point.x - startPointX

    console.log("Pan Result", startPointDelta, info.point.x, startPointX)

    if (startPointDelta < 0) {
        console.log("swipe left")
    } else {
        console.log("swipe right")
    }
}

function onPan(event, info) {
    console.log("Pan", info.point.x, info.point.y)
}

return {
    onPanStart: onPanStart,
    onPanEnd: onPanEnd,
    onPan: onPan,
}

}

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

No branches or pull requests

1 participant