I'm trying to create a scroll view that keeps on repeating its elements. Let's say it has 10 elements, so after the 10th element, the 1st element would show up and so on, infinitely.
NOTE: I'm not talking about infinite scrolling to load more elements. Just a cyclic structure in scroll view.
The solution that came to my mind is that a normal scroll view with those 10 elements, and every time I reach the end and invoke onEndReached, it will append those 10 elements ahead of it and give it an illusion that it actually is cyclic or looping nature. Only problem is that it doesn't sound efficient, like, storing duplicate elements on and on, every time you reach the end, into the data array. Is there any better solution possible?
There is a library called react-native-snap-carousel here in the GitHub that represents a rich carousel. Maybe you can get better ideas.
Another issues in the solution that you mentioned is when you go to the first of the scroll view, then duplication won't solve any problem.
EDIT 1:
Another library is react-native-swiper.
Related
I am working on a page where there are two rows in the header.
The first row has a "My Account" icon, Company Logo, and Logout.
The second row has a navigation bar.
When the Focus Ring/Focus Indicator highlights an item on the first row, the bottom of the focus ring is cut off by the navigation bar in the second row.
I am not allowed to change the spacing of the elements on the DOM.
Is there a way I can change the layering so that all of the elements on the page are not changed in size or location, but the Focus Ring is not cut off by the navigation bar?
The site built with React.
I've tried googling a number of things, but haven't turned up much specific to this issue.
I'm a little new to programming (my first job, first year). I'm not totally sure where to even start.
You are looking for z-index. The second element is positioned in front of the first element and so it covers the focus indicator.
This allows you to specify how far 'forward' elements are on the page.
Assuming nothing is using fixed or absolute position within the <div>s you are working on this should solve your issue.
i.e.
<div class="container">
<div id="behind" z-index="1"></div>
<div id="infront" z-index="0"></div> <!--The z-index is not really needed here so try without it first, it is to illustrate that the item in front at the moment should have a lower z-index than the one at the back-->
</div>
You may need to play with the z-index in order to get this to work (you can go to 999999 without a problem, but try and use as low a number as possible).
You may also have to fiddle with heights of elements if the site is poorly designed but without a code example I can only offer general advice and gotcha's
Without a code example it is difficult to suggest a solution, but it sounds like your two rows are overlapping, and thereby hiding part of the focus indicator.
Three different solutions come to mind,
Change the height and placement of the two rows to avoid the overlap in the first place
Try using the CSS z-index property to control which element is rendered foremost
Using the CSS outline-offset property, with a negative value, i.e. -5px, to shrink the focus indicator and hopefully making it visible
I've modeled using helixtoolkit which is done in a wpf user control library and hosted on ElementHost. I decided to do this because my model is fairly simple (just a stick element with lineVisual3d and bunch of small spheres).
Now I want to animate it and everything I find related to animation seems too complicated for what I'm trying to accomplish. I've seen storyboard being suggested as well as transform methods.
What I have is a 3D line connected by a bunch of points3D and I want to translate them only by a series of values at a fixed time increment.
I did this in a 2D graph using a timer for winform and even a forloop did the trick.
However, I'm not sure how to do the same for a 3D line element. I was thinking that since I have a simple structure simply redrawing it would suffice.
But my problem is I want to add a slider which acts in pretty much the same way as a video player, it will increment itself as the animation runs, I want to also be able to freeze it at any point in time and use the slider to go to any point in time much like how a video player works.
My biggest question here is how do I use a slider to control the animation. Again, this animation will simply be a bunch of values that I want to translate the stick element by(a series of points).
I've already got the values but I want to add an animation for these values at every increment while being able to control it using a slider.
--I will post any code if necessary, not posting any right now because I dont know what would help explain the question better
You can use TranslationTransform3D and apply the transform onto the 3D Model
React DnD doesn't appear to scale well.
I have a list of five hundred drop targets and it take several seconds to pick up an element.
Is there anyway of speeding this up?
The list scrolls perfectly smoothly.
I'm using react-virtual to reduce the number of DOM elements in existence, although unfortunately the drawing performance is well behind native rendering.
Also, a helpful thread...
https://github.com/react-dnd/react-dnd/issues/421
While technically you can stretch React DnD performance to ~3000
items, there’s no way for it to not lag after a certain point without
changing the API (and making it less useful). If you have thousands of
rows, I think you should be using virtualized lists anyway.
io3d.scene.getAframeElements api returns the waypoints
<a-entity tour-waypoint="TOP VIEW" io3d-uuid="2c0c947b-5135-456d-9626-8c80778b9dd5" position="" rotation="" scale="" visible=""></a-entity>
The position and rotation are empty. How can I get the pose data for each waypoints ?
Took us a while to figure this one out, sorry for the delay.
First things first, it worked with A-Frame just fine as this glitch demonstrates. The fact that the position and rotation don't show up in source code doesn't mean they don't work.
The reason for that is that A-Frame turns the attribute values into objects and objects aren't displayed in HTML sourcecode as (per standard) attribute values have to be strings. The fact that they aren't is not caused by us but by A-Frame and is, in fact, not a problem normally - it's the opposite as it is an optimisation.
Now you might want to show the information as part of an HTML dump (e.g. by displaying innerHTML in a textarea, then this is a problem.
That problem can be overcome by calling flushToDOM on the elements, like in this glitch. This affects all dynamically created A-Frame elements, not only 3d.io elements, by the way - you see this with the box element.
I hope this answers your question?
I am currently attempting to write a control(s) that will display a collection of elements, each of which have a start time between 0 and 1. The desired visual look we're aiming for is something akin to a simple timeline.
I've already created a FrameworkElement that renders an individual element as a line (this line represents the transition between one element and the next, e.g. y(x) = x) and my intention is to use this element as part of the DataTemplate for my custom ItemsControl. By flipping the odd elements horizontally and butting them together in a panel, it should be possible to see a continuous series of transitions between the elements. I'm having difficulty in deciding how to implement this panel, in particular with filling 'dead space' that might occur at the start of the panel.
The collection of elements that I'm trying to draw represents a looping effect, but the first element may not start at time T=0. Because the effect loops back on itself this means that the gap between T=0 and the first effect's start time is actually made up of the final part of the last element in the collection. This means I have to find a way of chopping up the last visual element in the panel so that the front part sits at the end of the panel and the back part sits at the start.
Another way to think of this is in terms of a circle/pie chart - if element A starts at 15% and element B starts at 50%, element B would occupy the regions 50-100% and 0%-15% continuously.
I'm really looking for a way to get this done in WPF visually rather than by modifying the collection of items (e.g. by adding a fake 'padding' element between 0 and the first element) as this would create complications down the line when it comes to things like modifying/selecting items, etc.
Someone has suggested drawing this as a 0-1 effect (removing any offset on the first element if there is one) then recreating the offset using a pair of cameras/viewports, which is something I'm not familiar with and seems a bit overkill. Can anyone suggest a simpler or more elegant way?
The 3D XAML question posed below contains code that achieves the kind of effect I was looking for, with some modifications. I set it up as an orthographic camera and made the position and texture co-ordinates of the MeshGeometry3D into dependency properties:
Why does TextureCoordinates work as expected for a Viewport2DVisual3D, but not for a GeometryModel3D?