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

Store neko position across pages #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

st4rburn
Copy link

Basically what it says, it's just a solution for #10 using local storage

@adryd325
Copy link
Owner

I like this! If you'd like some more stuff to do, make the localStorage entry only change on page beforeUnload. If not i'll merge it once I have the time to implement that

I might also wanna see if i can make this configurable with like data-neko-localstorage-pos or something with a better name on the script element

Thank you for your PR c:

@st4rburn
Copy link
Author

Thank you!
Oh true, I didn't even think of that. I'll try after work if I get a chance

And do you mean like as a bool or the key name or something else? I should be able to do that too c:

@adryd325
Copy link
Owner

i meant like, on the script tag you can have <script data-asdf="true" src="./neko.js"> and access it in js from document.currentScript.dataset["asdf"]

if "asdf" is true then persist data across navigation, else dont save or read localStorage

you could call it "data-persist-position" or something

@st4rburn
Copy link
Author

Ohh cool okay
Btw working on this I noticed beforeUnload not getting called, and it turns out the event isn't fired when there isn't interaction, or at least I can't get it to fire on Firefox, so I don't think that method will work on a lot of websites/browsers
It is kinda cursed just calling it after every frame but I'm not really sure if there's a better way to do it if we need user interaction so :/
Going to work on the data attribute now though

@st4rburn
Copy link
Author

It can be set based on data-persist-position now c:
I've set the default to true as well but it's just a bool so easy to change that

@Mrgaton

This comment was marked as off-topic.

@Mrgaton
Copy link

Mrgaton commented Sep 28, 2024

Ohh cool okay Btw working on this I noticed beforeUnload not getting called, and it turns out the event isn't fired when there isn't interaction, or at least I can't get it to fire on Firefox, so I don't think that method will work on a lot of websites/browsers It is kinda cursed just calling it after every frame but I'm not really sure if there's a better way to do it if we need user interaction so :/ Going to work on the data attribute now though

what about

window.navigation.addEventListener("navigate", (event) => {
    console.log('location changed!');
})

@st4rburn
Copy link
Author

That specifically didn't work but I just got data to store with both unload and beforeunload even though it was the same as I used before? So going to see if I can make that work again

@Mrgaton

This comment was marked as off-topic.

@st4rburn
Copy link
Author

Turns out I did a stupid and tried to add the event to document at first and just never realised, but I think it only works for window
So it works now lol

@adryd325
Copy link
Owner

would be cool too to add an option to set oneko size via style like

		nekoEl.style.transform = 'scale(1.8)';

please make issues for feature requests rather than making requests in an unrelated pull request

@Mrgaton
Copy link

Mrgaton commented Sep 28, 2024

would be cool too to add an option to set oneko size via style like

		nekoEl.style.transform = 'scale(1.8)';

please make issues for feature requests rather than making requests in an unrelated pull request

okay :C

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

Successfully merging this pull request may close these issues.

3 participants