Code Monkey home page Code Monkey logo

Comments (3)

nicg6645 avatar nicg6645 commented on September 23, 2024

This issue is being addressed in disable_scroll

from arcade.

nicg6645 avatar nicg6645 commented on September 23, 2024

So Game.setAttribute("position", "fixed") definitely fixes the scrolling issue. However, setting the position to fixed moves the canvas slightly to the left in the demo game, and also prevents you from scrolling to read the instructions.

When I looked at this on Sunday, I tried to do something a bit more complicated so that you could still scroll on the page before starting the game (i.e. creating a button over the canvas that fixes the position when clicked). Changing the position on click still causes the demo game to move slightly, which isn't ideal.

Of course, these issues might be unique to how game-demo.html is formatted. I'm curious if anybody has any input. Would you guys prefer to have the page load with position fixed, or to do it on click, which could possibly rearrange some CSS stuff?

from arcade.

sifferman avatar sifferman commented on September 23, 2024

Oh shoot! I didn't think about that. This is what I think could work:

setting the position to fixed moves the canvas slightly to the left in the demo game,

You can fix this with:
Canvas.style.position = "fixed";
Canvas.style.top = "50%"; Canvas.style.left = "50%";
Canvas.style.transform = "translate(-50%,-50%)";

This will center position absolute/fixed items.


and also prevents you from scrolling to read the instructions.

That's probably fine. I say we should just hide everything on the screen that's not the game window. I think the best way is to add a huge box shadow:
Canvas.style.boxShadow = "0 0 0 100vmax black";

from arcade.

Related Issues (6)

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.