The AngularGrid library has been reported to generate blank areas in certain unique scenarios

I have implemented Angular grid to create a fluid layout of items on my page, similar to Pinterest. While it generally works well, I am encountering an issue where there is empty space in some cases because the position of item7 seems to be calculated incorrectly. https://i.sstatic.net/ZS62L.gif I am utilizing AngularGrid from this source. The code I am using closely follows their documentation, with the exception that instead of an image, I am using a custom component within ng-repeat, like this:

angular.module('app').controller('demo', demo);

function demo($rootScope, $scope, apiService, angularGridInstance) {
    var self=this;
    this.noOfProjects=8;
    this.firstNo=0;

    this.loadedProjects;
    this.totalProjects;

    apiService.searchProjects($rootScope.userId, self.noOfProjects, self.firstNo).then(function(response) {
            console.log(response.data);
            self.loadedProjects = response.data.matches;
            self.totalProjects  = response.data.header.totalCount;

            console.log(self.loadedProjects);
            $scope.pics=self.loadedProjects;
        });
    
}
.dynamic-grid{
            position: relative;
        }
.angular-grid > *{
opacity: 1;
}
        .dynamic-grid.angular-grid{
            display: block;
        }

        .grid {
            position: absolute;
            list-style: none;
            background: #ffffff;
            box-sizing: border-box;
            -moz-box-sizing : border-box;
            overflow: hidden;
        }
        .grid-img {
            width: 100%;
            vertical-align: middle;

            background-color: #fff;
            
        }

        .grid-img.img-loaded{
            visibility: visible;
            opacity: 1;
        }
<div class="" data-ng-controller="demo">
    <ul class="dynamic-grid" angular-grid="pics" grid-width="300" gutter-size="10" angular-grid-id="gallery" refresh-on-img-load="false" >
        <li data-ng-repeat="project in pics" class="grid" data-ng-clock>
            <project-info-min-grid project="project" class="grid-img" ></project-info-min-grid>
        </li>
    </ul>
</div>

Seeking assistance for this issue. Any help would be appreciated.

Answer №1

After conducting some research, I discovered that the issue was caused by specific CSS affecting certain parts of each item's content:

    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

To address this, I implemented a JavaScript function to shorten the string dynamically:

var maxLength=100;
            if(self.project.description){
                if(self.project.description.length > maxLength) {
                    self.project.description = self.project.description.substring(0,maxLength-1)+"...";
                }
            }

This solution resolved the issue successfully. For anyone facing a similar problem in the future...

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

How can I retrieve all the data for the chosen item in a mat-select within a mat-dialog, while still preserving the code for setting the default selected value

In my modal dialog, I have a dropdown menu populated with various languages. The ID of the selected language is bound to the (value) property for preselection purposes when data is passed into the dialog. However, I am looking for a way to also display the ...

Creating a Fixed Header and Footer in HTML When Content Exceeds a Specific Height

Imagine an HTML template with the following structure: ------------- |Header Data| ------------- | | | Main Data | | | ------------- |Footer Data| ------------- The Header Data, Main Data, and Footer Data sections have fixed height va ...

In next.js, when using the DELETE method, make sure to utilize a query parameter rather than

As I work on developing an API, I have encountered an issue with the delete functionality not functioning as expected. When sending a request, I receive a response from this URL: http://localhost:3000/api/admin/categories?id=1 instead of from this URL: ht ...

Receiving error message "51 F02 FacebookConnectPlugin sClass not found" while attempting Facebook login with Ionic and Cordova

I have been working on integrating Facebook login into my application. I followed the steps outlined in this Ionic blog: "". However, I am facing an issue where the login process is failing at $cordovaFacebook.login and not proceeding further. $scope.fb ...

Server Receiving Missing Post Parameters

I've developed a straightforward $resource factory. .factory('Order', order) order.$inject = ['$resource', "ApiEndpoint", "UserRecord"]; function order($resource, ApiEndpoint, UserRecord) { return $resource(ApiEndpoint.url + & ...

alter the color of the accordion display

Good day everyone, I am seeking help with a Bootstrap query. Here is the HTML code I am working on <!DOCTYPE html> <html lang="nl-NL"> <body> <div class="container-md"> <br> <div c ...

Issues with resetting AngularJS form---"The AngularJS form

I have been putting in a lot of effort to make this work. Despite my knowledge about child scopes, prototypal inheritance, and the use of dot notation for the model, I am facing an issue with resetting the form. You can access the hosted form here. The rel ...

What is the best way to pass the value from one textfield to another using material UI in a react application?

I'm looking to transfer the content from a text field in a dialog window to another text field that is not embedded. However, instead of transferring the actual text field value, I'm getting an output of "object Object". Can you help me figure ou ...

Optimizing Performance by Loading Critical CSS in Next.js

Would it be possible to split critical CSS from non-critical in Next.js and load the non-critical asynchronously on each page? I have styled-components implemented in my pages and components along with a few external CSS libraries. Any suggestions or tip ...

"By clicking on the image, you can trigger the transfer of data to the view.py file

Check out my image in two.html: https://i.sstatic.net/FhKlz.png <td> <img src="http://127.0.0.1:8000/imageAll/101.png" width="100"; height="300"> </td> I need to pass the data value of 101 to my view.py wh ...

Making adjustments to the Bootstrap CSS design by removing certain elements

I have inserted a styling link from Bootstrap into the header section of my page, but it is applying additional styles to my cards which I don't want. Is there a way to eliminate these unwanted styles without removing the Bootstrap CSS link? Below, y ...

Is there a way to assess Python code within a document's context using JavaScript in JupyterLab?

When using Jupyter Notebooks, I can create a cell with the following JavaScript code: %%javascript IPython.notebook.kernel.execute('x = 42') After executing this code, in another cell containing Python code, the variable x will be bound to 42 a ...

Exploring the functionality of Leader Line in VueJS

Attempting to implement Leader Line on VueJS has presented some challenges that have yet to be fully resolved online. The installation of leader-line using npm was successful - npm install leader-line Below is the code for the vuejs file: HTML: <div ...

Generate a random post on a Blogger page upon loading instead of clicking on it

I recently implemented a random post button on my website at . I am now looking to have a random post load automatically when the page loads instead of requiring users to click the button. Can anyone provide guidance on how I can achieve this? Below is t ...

What causes the HTML5 validator to detect errors?

Having trouble understanding! really ... <!DOCTYPE html> <html lang="fr"> <head> <meta charset="utf-8> <title>The Digital Revolution</title> <meta name="description" content="The Digital Revolution"> ...

How can I update data in Select2 after it has been initialized?

After initializing select2, I am trying to set an array of data in the following way: var selection = $('#selection').select2({}); selection.data([ {id: 1, text: 'value1'}, {id: 1, text: 'value1'} ]); However, I am encou ...

Is my Angular controller making an excessive number of HTTP requests?

In my Angular controller, I have the following code: $scope.openCat = function(catId) { $http.get('/api/cat/' + catId). success(function(data) { $scope.sortedArticles = []; var lst = data.articles; lst.forEach ...

How does jquery's removeClass function on a button continue to function smoothly even after an ajax call

Code Snippet: <span class="input-group-text"> <button type="button" class="btn btn-outline-danger btn-sm owner_button owner_check" name="owner_check" > <i class="far fa-check-circle"></i> </button> </span> ...

JavaScript progress bar disappears when displayed, but fails to indicate progress

When I click the button, I want a progress bar to appear and then update its progress. However, in my current code, the progress bar shows up but does not update. If I remove style="display: none", the progress bar updates as expected. Any sugge ...

Mastering the correct application of flex properties within nested flex containers

I'm struggling with utilizing flexbox properly and would like some clarification on how nesting parent and child elements functions. I understand that the child elements inherit the parent's flex properties, but I'm unsure if this inheritan ...