Innovative idea for a time management system based on timelines and scheduling

My latest project involves creating a scrollable scheduler, inspired by vis-timeline and built using Vue.js.
One of the main challenges I'm facing is achieving smooth infinite scrolling in all directions (past and future).

I must confess that I'm still relatively new to programming, so I would greatly appreciate any feedback or evaluation of my approach.

This is what my current solution looks like:

JS:

let datelist = [yesterday, today, tomorrow]

HTML:

<div v-for="date of datelist">
    <div width="100%" height="100%">{{date}}</div>
</div>

Since 3 divs occupy 300% of the screen space, it causes overflow (visible scrollbar). After rendering, I center the middle one (today).

When scrolling via drag-and-drop and 50% of the previous or next day is visible, an event is triggered to update the datelist:

Scrolling left:

*Generate yesterday's date and remove tomorrow *

datelist = [yesterday -1 day, yesterday, today]

Scrolling right:

*Generate tomorrow's date and remove yesterday *

datelist = [today, tomorrow, tomorrow + 1]

However, this approach has its drawbacks:

Every time the list changes, it needs to be fully re-rendered. If each day ends up having a lot of content later on (like appointments), it could impact performance.

You can only scroll linearly with this method, and if you want to jump to a specific date, say using a date picker, the entire list needs to be regenerated.

Perhaps more challenges ahead?

How would you tackle this problem? I am more interested in the process of finding a solution rather than just the solution itself.

Constraints:

  • No third-party libraries
  • Optimal performance
  • Simplicity

Answer №1

To achieve the desired functionality in your project, utilizing the IntersectionObserver API is highly recommended. This will allow you to customize behavior, fetch content dynamically, and enable interactive features for the "date cells" within your application.
For a convenient solution, consider integrating the useIntersectionObserver composable.


If you aim to optimize performance by displaying only visible content and minimizing DOM clutter, tools like virtual scrollers may be beneficial. Alternatively, custom implementations can also achieve similar results (refer to provided source code).


In cases where list re-rendering is necessary, it's advisable to apply specific modifications at targeted locations rather than resetting the entire list. Experiment with memoization techniques using resources like memoize hooks to streamline this process efficiently.
By strategically managing data visibility through CSS styling or off-screen positioning, you can retain historical date entries without removing them entirely from the list. Consider incorporating boundary logic into your approach for seamless transitions.


In summary, when facing constraints, prioritize optimizing two out of three aspects based on project requirements.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Sorting the output with gulp and main-bower-files (gulp-order is not functioning)

Hello, I'm a Java engineer diving into the world of Javascript for the first time. Apologies in advance if my information is lacking or incorrect! I am currently working on a gulp build script and utilizing bower to manage dependencies for my JS fron ...

Issue with jQuery fadeTo() not working after appendTo() function completes

I am facing a problem with the code below that is meant to create a carousel effect for my website. The main issue I am encountering is that the original fadeTo() function does not actually fade the elements, but rather waits for the fade time to finish an ...

Using jest.fn() to simulate fetch calls in React

Can anyone explain why I have to include fetch mock logic within my test in order for it to function properly? Let's take a look at a simple example: Component that uses fetch inside useEffect and updates state after receiving a response: // Test.js ...

Is it possible to embed an array within an object by utilizing the name attribute in a form?

I am currently developing a full-stack application where I have a form that submits data to one of my post routes. In this form, all input fields are grouped into req.body.model. This is made possible by adding a name attribute with square brackets around ...

Retrieve the present value from a Selectpicker using jQuery within the Codeigniter Framework

I attempted to use DOM manipulation to retrieve the value of the currently selected option from the selectpicker. My goal was to have the value of the selectpicker id="service_provider_select" printed first. However, whenever I changed the option using the ...

Is it possible to update parent data using a child component?

What is the correct way to update parent data using a child component? In the child component, I am directly modifying parent data through props. I'm unsure if this is the right approach. According to the Vue documentation: When the parent proper ...

Unable to retrieve JSON data in servlet

I am having trouble passing variables through JSON from JSP to a servlet using an ajax call. Despite my efforts, I am receiving null values on the servlet side. Can someone please assist me in identifying where I may have gone wrong or what I might have ov ...

Obtain image URL from object properties using AngularJS

Just starting out with Angular JS and I have a question. I'm currently working on a project and I have a solution in mind, but I was wondering if there's a more "angular-esque" approach that I could take. The idea is for each videoid, there wou ...

Create a custom VueJS component by utilizing an npm package

Looking to navigate around X-frame restrictions? You can check out this npm package: https://www.npmjs.com/package/x-frame-bypass To make it work, include the following tag within your HTML: <iframe is="x-frame-bypass" src="https://example.org/">& ...

How can you decode JSON using JavaScript?

Need help with parsing a JSON string using JavaScript. The response looks like this: var data = '{"success":true,"number":2}'; Is there a way to extract the values success and number from this? ...

The transparency of an image is being lost when it is used in a modal

I am facing an issue when trying to append a modal that contains only a transparent gif. The problem arises when the transparent background of the gif is not displayed properly. There seems to be no issue with the transparency settings of the gifs themselv ...

Tips for validating user input within a specific range in React?

I need to restrict user input in an input field to a number range defined by minimum and maximum values. I am working on this functionality using React/Next js. <Input value={tripCoverage} onChange={(e) => { const value = e.target.v ...

Changing the size of icons in an Alert using Material UI with React

Recently, Material UI unveiled the new 'Alert' component. Everything seems to be working well, except for the fact that I can't find a way to adjust the size of the icon. Here is my code snippet: <Snackbar open={true}> <Alert ...

AJAX cached outcomes

Trying to educate myself on AJAX using w3schools.com, but struggling with a particular example: xhttp.open("GET", "demo_get.asp", true); xhttp.send(); In the above example, there might be a cached result. To prevent this, you can include a unique ID in t ...

Is polymer routing the best choice for large-scale websites?

I am currently working on a large project that consists of various layouts and structures, totaling around 100 different pages. Despite the variations in content, the core elements such as headers and menus remain consistent throughout. To streamline my ...

Firebase's equalTo function seems to be malfunctioning

Having encountered an issue with Firebase, I am currently attempting to fetch all of my posts in JavaScript. Specifically, I am looking for posts in the correct language that are marked as "published" and sorted by their published date. In my Firebase dat ...

Unable to retrieve JSON data using jQuery

When working with jQuery to retrieve JSON data, I encountered an issue. After storing the data in a variable named "ajaxResponse," attempting to access specific data points resulted in an error stating that ajaxResponse.blah is not defined. Interestingly, ...

How to Override Certificate Expiry in JavaScript

Is there a way to bypass security for an expired certificate when making an Https post request in Javascript? I have been successful in doing this with C# and Java, but unsure about how to proceed in JavaScript. function post() { var xmlhttp; xmlhtt ...

Vue.js dynamic HTML elements are constantly changing and evolving

Is it possible to dynamically add elements to the content? See example below: <template> {{{ message | hashTags }}} </template> <script> export default { ... filters: { hashTags: function(value) { ...

Navigating to JSON input in Express correctly

I have successfully created a basic Express-based API to serve JSON data, but now I want to enhance its functionality. The JSON file follows this structure: (some sections are excluded) [{ "ID": "1", "NAME": "George Washington", "PAGE": "http://en.w ...