Is there a way to determine the number of Waypoints that are currently toggled simultaneously?

I have a collection of elements arranged in rows and I am applying Waypoints instances to them.

<div class="row">
  <div class="col-xs-6 col-sm-4"><div class="foo"></div></div>
  <div class="col-xs-6 col-sm-4"><div class="foo"></div></div>
  <div class="col-xs-6 col-sm-4"><div class="foo"></div></div>
  <div class="col-xs-6 col-sm-4"><div class="foo"></div></div>
  <div class="col-xs-6 col-sm-4"><div class="foo"></div></div>
  <div class="col-xs-6 col-sm-4"><div class="foo"></div></div>
</div>

I want to track the total number of active Waypoint instances simultaneously, specifically for each .foo element on the same row:

var total = 0;

$('.foo').each(function() {
  $(this).waypoint({
    handler: function(direction) {
      total++;
    }
  });
});

The current code works for the first row, but I'm unsure how to reset it before the elements in the second row become active (to count Waypoint instances for the elements in subsequent rows). Any suggestions?

Answer №1

To determine the total count of simultaneously triggered Waypoints instances, use this.group.waypoints.length. Further information can be accessed here: .

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

Condense a lineup of names into only two rows

I have a challenge where I need to showcase a list of names separated by commas, pulled from an array in my React component. The HTML output should appear as follows: <div> <span>Liza</span>, <span>Eric</span>, <span>Mic ...

What is the rationale behind setting the argument rv to zero in the make_response function within the Flask Python file app.py?

I have been working on a project where I take input numbers from a flask website and feed them into a neural network. The outputs are then stored in a dictionary which is displayed on a result page with a table. Below is the relevant code snippet for Fla ...

Tips for combining enable and disable properties in flatpickr.js?

I'm facing a challenge with using both the enable and disable properties in flatpickr.js. The enable property returns a range of dates that should be enabled, but I specifically want to disable certain days within that range, like weekends. datePicker ...

Using Jquery to encase an element in a div while scrolling down and removing it while scrolling up

After some experimentation, I've managed to wrap an element inside a div using jQuery. My next challenge is to wrap it as you scroll down and unwrap it as you scroll up. Do you think this is achievable? Although I have succeeded in wrapping it while ...

The art of linking subscriptions

Greetings! I am currently attempting to connect multiple subscriptions together. changeBranch() { const bottomSheetRef: MatBottomSheetRef = this.bottomSheet.open(CCSBranchComponent, { data: this.branches }); this.subscription.add(bottomSheetRef.instan ...

Adjust the height of the Twitter Widget to be proportionate to the height of its parent div dynamically

I have integrated the Twitter widget into my library management system, but I am facing an issue with its fixed height. Is there a way to make the height dynamic through CSS? Any suggestions on how this can be achieved will be greatly appreciated. Below ...

What could be causing the mysterious line appearing underneath my bootstrap forms?

I have created a CSS sticky footer that is designed like so: #foot { position:fixed; left:0px; bottom:0px; height:30px; width:100%; text-align: right; padding-top: 7px; font-size: small; background-color: none; } However, a mys ...

Is there a way to enable Tail Recursion Optimization in TypeScript?

const isPositive = (n: number) => n > 0; function fitsIn(dividend: number, divisor: number, count: number, accum: number): number { if (accum + divisor > dividend) { return count; } return ...

Creating custom styles using Material-UI's makeStyles function with both before and after

Currently, I'm tasked with a project that involves utilizing the CSS code below. .hexagon, .hexagon::before, .hexagon::after { width: 67px; height: 116px; border-radius: 18%/5%; } I am wondering if there is a method to apply the specified style ...

What is the method for avoiding short-circuit conditions in TypeScript?

Is there a way to evaluate conditions in TypeScript without using short-circuiting? TypeScript does not support & or | for boolean types. I need to avoid short-circuit checking because I call the showErrors function inside the isValueValid function. C ...

Choose between creating an observable pipe within a function or storing it in a variable

Currently, I have a functional code snippet that leverages the Angular service to create an Observable pipeline. This pipeline utilizes operators like mergeMap, filter, map, and shareReplay(1) to manage user authentication and fetch the onboarding status f ...

Adjust the line height appropriately to prevent any text from being cut off

I need a solution for displaying multiline text in a div with overflow:hidden without clipping the text. Here's an example of clipped text: I want to achieve this using only Pure CSS, without relying on Javascript. If my div has a fixed height, I c ...

Could you advise on the best placement for my upcoming JQuery animation?

Here is the code I am currently working with: $(function() { $("button").click(function() { $("#box1").animate({ left: $(window).width() - 800 }, { complete: function() { $("#box1").hide(); } }); $("#box2").a ...

The angular controller erroneously indicates that the modal form is valid even though it is not

I am currently working with a form that appears in a modal directive using bootstrap UI. The form consists of 2 input fields with html5 validation set to "required." Initially, in the controller, I tried to check if the form is valid before proceeding to ...

The Datatables render function seems to be inactive

$("[data-manifest-table]").DataTable({ "processing": true, "serverSide": true, ajax: { url: "LoadManifestData", type: "POST", data: { FilterItem: new FilterItem($("[data-statuses]").val(), $("[dat ...

Simultaneously removing and inserting components with Meteor.js

I have a straightforward set of items that is displayed like this {{#each items}} {{> item}} {{/each}} My code defines that only the three most recent items are shown return Items.find({}, {sort: {timestamp: -1}, limit: 3}) Whenever a new item i ...

Making changes to JSON format post $.get function

Struggling to make sense of the JSON properties I receive from the server. Any advice on how to change the format would be greatly appreciated. Here is a snippet of the received data: [ { "date": "2006-07-01T00:00:00.000Z", "date_processed": "2 ...

Tips for sending formData (file upload) via jQuery ajax with MVC model

My Web Development Challenge : //IMAGE UPLOAD var formData = new FormData(); var totalImages = document.getElementById("ImageUpload").files.length; for (var x = 0; x < totalImages; x++) { ...

Adding an item to a nested array within an object in a Redux reducer

Here is an example of my initial state: let initialState = { data: { name: 'john', books: [ { name: 'a', price: 220 } ] } } Is there ...

1 in every 3 divs in jQuery, chosen randomly

Hey there! I have a fun project in mind - programming a "Rock Paper Scissors" game with the computer. The only issue is figuring out how to make the computer choose a random object after I pick one of the 3 options. Here's what I've come up with ...