Disabling / Hiding Anchors

Is there a way to disable an anchor? I’m using anchors to trigger automatic snap/scrolls on a long page. In order for this to work I must be able to disable anchors under certain situations.

If not I may have to resort to empty buttons I can hide/disable.

Thanks in advance!
David

@dwklink if...else - JavaScript | MDN
:slight_smile:

Ha - thanks for the direction! I hadn’t thought of including conditions… seems to work on my first test.

export function anchorFeature1bot_viewportLeave(event) {
  if (page==='f1') {
        page='home'
        wixWindow.scrollTo(0,0) 
        ...

I swear I feel like I need to do disable anchor but yeah

So I have a question… If an anchor can be hidden on load via Properties, then how does one un-hide it?

@dwklink Any reason you need to hide it on load? I suppose if you want it to be “disabled” on load, then you can “show” it using any event listener from any element on the page.

@David Thanks for your response!

Basically I’m hiding certain anchors because they are interfering with other scroll events - and I’m trying to avoid overly complex conditional statements.

Can you further describe how to “‘show’ it using any event listener from any element on the page.?”

I’ve attempted to use the usual:

$w('#anchorFeature1topleave').show()

But I get an error that ‘show’ does not exist on ‘#anchorFeature1topleave’. I’ve also tried to expand, but that doesn’t work. If I have the option to hide it on load, there MUST be a way to show it, no?

@dwklink It sounds like you’ll probably be better off using wixWindow.scrollTo(x, y).

You won’t have to worry about using anchors at all, and you should be able to plug it in neatly using your current conditional statements. Just make sure to import the wix-window API.

@skmedia Thanks again for the reply. I really appreciate you taking the time to offer suggestions.

I need anchors to trigger events when they leave the viewport. I’m building a snap when scrolled type of a page. For example if the visitor starts to scroll down, #anchor1 leaves the viewport and the page snaps via scrollTo to x,y. The issue is certain anchors interfere with other scrollTo events as they pass through the viewport.

I can create conditions using variables, and that’s what I’m defaulting to now. If I could hide and unhide the anchors, life would be a bit easier.

Unfortunately I can’t seem to find an answer the question of how you unhide an Anchor that’s hidden on load. Is this a bug or an incomplete feature?

Tried calling support but they don’t help with Corvid…