Git Product home page Git Product logo

smoothscroll's Introduction

drawing SmoothScroll

A customizable SmoothScrollContainer node for Godot

Watch video footage on Youtube

How to use

Activate the addon in the project settings' addon tab, Click the "+" button to add a new node and select "SmoothScrollContainer" instead "ScrollContainer". To add smooth scrollling to existing ScrollContainers, rightclick the node and select change type. Then select "SmoothScrollContainer".

For smoother scrolling: In your project settings set gui/common/snap_controls_to_pixels to false

Mouse scroll icon by Greg Fiske from the Noun Project

smoothscroll's People

Contributors

dannymate avatar gducrash avatar haroldlever avatar scgm0 avatar spyrexde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

smoothscroll's Issues

Weird flickering when overdragged and scrolling the opposite direction

To reproduce and for the effects to be more visible:

Make a SmoothScrollContainer that has a VBoxContainer as a child
Add a lot of ColorRect nodes as children of the VBoxContainer so we can scroll
Set Speed to 10
Set Damping to a small value like 0.05 or 0.1
Scroll past the top(overdragging) and quickly scroll down to notice the 1 frame "snap" that occurs
Scroll past the bottom and quickly scroll up for the same thing to happen
Has something to do with this line of code set_v_scroll(-pos.y) because when I remove it, it works fine, but that removes the smoothness of the scrollbar

Weird behaviour with change_scene()

So I've got a main menu, it has a few buttons which just change the scene. One of those scenes contains the SmoothScroll Container and for some reason when I change the current scene to that one the container doesn't smoothly scroll.
I've sort of found out that the issue may be in these lines of code in the _process() function:

if content_node.rect_size.y - self.rect_size.y < 1:
	return

When I remove these lines and change to the scene, it scrolls smoothly but for some reason the scroll bar appears on the left instead of the right and behaves very weirdly.

This is my first time writing an issue, so if there is some information missing let me know and I'll try to provide.

Setting horizontal and vertical scroll values does not work for SmoothScrollContainer

As in programmatically changing the scroll position via ScrollHorizontal/ScrollVertical. I imagine your script is overriding those, so this is not very surprising, but it is still something I consider undesirable.

If there is a method in SmoothScrollContainer to do this rather than directly setting ScrollHorizontal/ScrollVertical, how do I access the SmoothScrollContainer object from my own C# code (like what am I using to be able to extend that class)?

As before, plugin v1.3 and Godot v4.2.1.

Stuttering on slow movement

When setting a low scroll speed/friction the content is not moving smoothly anymore, framerate independent.
Could have something to do with the resolution or coordinates being floating-point numbers.

Screen.Recording.2024-04-07.at.18.10.29.mov

Scroll signals not being emitted

Like described in #30, the smooth scroll container does not emit scroll signals at all. An implementation must be suited for all types of scrolling (scroll wheel, drag bar and touch scroll) and should be dependent on the scroll containers velocity.

Possiblity of backport to 3.x?

For newbies like me, Godot 4 has many changes and very little documentation so far, regardless, this plugin is awesome,

Any chance you would consider back porting your Godot 4 version to Godot 3.x?

Touch pressing does not work when exporting to HTML5

When I export my game to HTML5, clicking on my TextureButtons stops working.

When running in Godot itself with mouse everything works fine, also when exporting to APK everything works fine.

When I took the button out of the SmoothScroolContainer it worked correctly and clicked even when exporting to HTML.

I attach the video, and the structure of my project.

This is the work on pc, here the button is pressed, and from hamster it says that there are not enough coins, everything works properly:

PC.Clipchamp.mp4

This is a recording of the screen from the phone, the game works in the browser in HTML5, on TextureButton do not lead to anything

video_2024-05-07_12-47-09.mp4

This is the structure of my TextureButton:
image

I tried to describe as much as possible, if there is any additional information I can provide, please write, I hope you can help me.

Godot version
Godot 3.5.3-stable

Godot4: Exported 'speed' variable cannot be altered

The speed variable of SmoothScrollContainer cannot be changed in the editor because the export tag defines the min value as 10 and the max value as 1. @export_range(10, 1)

Possible solution:
@export_range(0, 10)

General performance issue

Having a AMD Ryzen 9 3900X 12-Core CPU and a NVIDIA GeForce RTX 2080 Ti GPU im am only getting about 27 fps at max in the example scene. As soon as I remove the scroll container from that scene it goes up to over 120fps again.

Touch scroll not working in Godot 4

For some reason in Godot 4, _gui_input only gets triggered by InputEventMouseButton but not by InputEventScreenDrag or InputEventScreenTouch although Emulate Touch From Mouse is enabled. With just _input it works but then it also triggers with cursor or focus outside of the scroll container so it's no alternative.

Add counterforce for touch over-dragging

I already fiddled around a bit and came to the conclusion that such a mechanic is a bit more complex than it might seem at first. On Apple devices, over-dragging with touch is implemented in such a way, that as soon as the content gets over-dragged, the y-position of the gesture gets saved and the speed gets increasingly slower as the more you drag away from that position. The speed increases again when moving the finger toward that position and as soon you reach that position the speed is normal again. In this way, it feels like a seamless transition from something like a scroll and a stretching state.

Can't seem to set vertical scroll

Employing the following code doesn't seem to work for me. Seems pretty elementary, is there perhaps a setting to enable the use of script to adjust scroll position?
$SmoothScrollContainer.scroll_vertical = 0

The code is not in the ready function, and just in case I've also tried to defer to no avail.

Make scroll framerate independent

Currently, the framerate determines the speed, damping, friction etc. This means it's impossible to guess the actual end result people will get, since one person might have 30fps and another 500. High FPS results in very slow scroll with high friction, low FPS results in very fast scroll and less friction.

To reproduce, you can change the max FPS in the project settings (enable advanced) to some small value like 30, then remove the limit and test again.

Disabling "overdrag" not only does not prevent overdrag, but causes jittery movement on right and bottom edges

By "jittery" I mean trying to drag the pane around causes it to flicker wildly as it reaches the bottom or right edges of the valid scroll zone. So wildly in fact, that OBS cannot capture it properly.

In addition to this, I can still clearly drag it well past the left and top borders, which defeats the entire point of the option.

What I expected disabling the "Allow Overdrag" option to do was simply hard-limit the scrolling to within [0,size]. I saw on another issue here - related to overdrag - some debate over desired behavior, so I am going to say this in case this is for some reason not what that option is meant to do: I do not want phone-like UX, be that overdrag, "drag physics", or anything like that; I want a standard windows-style scrollable pane that also supports click-drag for movement.

SmoothScrollContainer script errors randomly on initialization: ParserError: Could not find "ScrollDamper" in the current scope

As seen here:

Thrown by this line of code, which is switched to and highlighted when the error occurs:

I have not seen any identifiable cause for the error, as when the error occurs I can just try again and it usually works (only to error again later). The only pattern I have been able to identify is that I have yet to see it error in two successive attempts. (This is not to say it errors every second attempt; it can go 2, 5, 13, or any other number of initializations between errors).

This is with the newest version of the plugin (downloaded yesterday) and the newest Godot as of a month ago, 4.2.1.

Cannot scroll down the length of content

Hello @SpyrexDE, thank you for the plugin. I can't seem to scroll down to the bottom of the page, I have tried to change many settings, but the scroll bar seems to get stuck about halfway down my page and does not reach the bottom. Is there something I'm possibly missing? Even in the example scene when I add more text it only scrolls down to the existing text not down to the text that I added? Thank you.
Godot 4.0.beta14

Dragging scroll bar presents weird behavior

Godot version

4.2.1 stable

Smooth scroll container version

d1a7891

Description

ScrollBarDragging1.mp4
  • h/v_scrollbar_dragging remains true when drags scroll bar until mouse enters content node's area.
  • any_scroll_bar_dragged() does not work, I guess it is because scroll bar 's 'focus_mode' is None by default.
ScrollBarDragging2.mp4

Then I tried to set scroll bars' 'focus_mode' to All, but something weird occurred.

  • Content node has offset when scroll bar is focused.
  • h/v_scrollbar_dragging and any_scroll_bar_dragged() remain true when drags scroll bar until lose focus.
  • Dragging doed not work when scroll bar is focused.

Steps to reproduce

Check properties on rich text label. Add these few lines in update_text() might help you check any_scroll_bar_dragged().

func update_text(ssc:SmoothScrollContainer):
	while true:
		await get_tree().process_frame
		new_text = ""
		for propertyInfo in property_list:
			var propertyName : String = propertyInfo.name
			var propertyValue = ssc.call("get", propertyName)
			var propertyType = propertyInfo.usage
			new_text += "[color=green]%s:[/color] %s\n" % [propertyName, propertyValue] if propertyType == 4096 else "[color=yellow]%s:[/color] %s\n" % [propertyName, propertyValue]
			# new lines
			if propertyName == "v_scrollbar_dragging":
				new_text += "[color=lightblue]%s:[/color] %s\n" % ["any_scroll_bar_dragged()", ssc.any_scroll_bar_dragged()]

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.