Questions tagged [snapping]
65 questions
31
votes
3 answers
How to snap RecyclerView items so that every X items would be considered like a single unit to snap to?
Background
It's possible to snap a RecyclerView to its center using :
LinearSnapHelper().attachToRecyclerView(recyclerView)
Example:
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?)…

android developer
- 114,585
- 152
- 739
- 1,270
17
votes
2 answers
How to get the center item after RecyclerView snapped it to center?
I'm implementing a horizontal RecyclerView that snap items to center after scrolling, like Google play App horizontal lists. This is a review.
My code is below:
MainMenuAdapter mainMenuAdapter = new MainMenuAdapter(this, mDataset);
final…

YUSMLE
- 705
- 6
- 21
12
votes
3 answers
Finding the closest grid coordinate to the mouse position with javascript/jQuery
What I'm trying to do is make a grid of invisible coordinates on the page equally spaced. I then want a
to be placed at whatever grid coordinate is closest to the pointer when onclick is triggered. Here's the rough idea:
I have the tracking…

Acorn
- 49,061
- 27
- 133
- 172
7
votes
3 answers
Snap to an index Lazyrow
I am making a calendar with the help of a lazyRow. I now have the problem that I want the row to snap to the index after a certain scroll amount so it shouldn't be possible to be stuck in between indexes. Is there a way to do that?
LazyRow(state…

jens
- 207
- 2
- 9
7
votes
2 answers
A pythonic way how to find if a value is between two values in a list
Having a sorted list and some random value, I would like to find in which range the value is.
List goes like this: [0, 5, 10, 15, 20]
And value is, say 8.
The standard way would be to either go from start until we hit value that is bigger than ours…

tm_lv
- 6,442
- 5
- 24
- 16
7
votes
1 answer
UIScrollView does not always animate deceleration when overriding scrollViewWillEndDragging
Here is my override code - it just calculates where to snap to:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
if(targetContentOffset->y <…

3rdFunkyBot
- 396
- 3
- 8
6
votes
1 answer
How to implement snapping in CollapsingToolbarLayout?
I have a collapsing toolbar layout, below that a tab layout and below that the corresponding viewpager. I want to implement snapping such that when I collapse the collapsing toolbar layout more than half and leave it, it should snap and collapse…

Amit Tiwari
- 3,684
- 6
- 33
- 75
6
votes
2 answers
how to handle SVG pixel snapping
I am trying to render two svg lines using path element.
The first line has 1px width and it is sharp
The second line has 2px width and it is blurred
The stroke-width is the same for both.
How to fix this
5
votes
3 answers
How to resample a raster snapping to an existing grid?
I would like to resample a raster from a high resolution to a low resolution (with different extent) in a defined grid cell. Is there a way of using an existing raster file as input for the snapping?
In the raster package, aggregate and resample…

Wraf
- 747
- 2
- 10
- 24
4
votes
1 answer
javascript - Drag and drop with intelligent snap guides
I am currently building a widget that will allow users to design a layout for an application-specific task. And I would like to provide a powerpoint/keynote-esque interface (a la 280slides) for the users. However, I would also like to provide "snap…

shachibista
- 287
- 3
- 11
4
votes
1 answer
Android ListView scrolling
I have an Android ListView with very tall rows and it like a vertical gallery of pictures. When I fling the view I would like it to precisely stop at the start of each view. Currently it will go over the next view and stop betwen 2 views which is…

Andrew Thompson
- 139
- 8
3
votes
3 answers
Building a drag and drop puzzle-type interface with snap alignment
I'm building an Android puzzle game where the user rotates and shifts pieces of a puzzle to form a final picture. It's a bit like a sliding block puzzle but the shape and size of pieces is not uniform - more like a sliding block version of…

PowRTocH
- 35
- 1
- 4
3
votes
3 answers
Snap a point to the closest part of a line?
I have a work order management system that has Python 2.7.
In the system, it is only possible to use the libraries that are included in the standard Python 2.7 library (it's not possible to import other libraries).
The system has lines and…

User1974
- 276
- 1
- 17
- 63
3
votes
0 answers
Snapping Horizontal Scroll View
In the Google Play store, there is a View showing screenshots for each app. It can be scrolled horizontally but it snaps to each screenshot. I need such a View in my app but I can't seem to find the API. Is this a standard View that I can implement,…

Zero
- 1,864
- 3
- 21
- 39
2
votes
1 answer
Snapping with CALayers
I am moving a few CALayers using the -mouseDragged method, and now I would like to "snap" them when they are sufficiently near (or when they are overlapping just a little bit).
Each layer is not a "square": I am drawing different polygons.
I…

Donovan
- 6,002
- 5
- 41
- 55