Is it possible for Masonry to incorporate RTL (Right-To-Left) direction?

Before, Masonry worked perfectly with the Left-To-Right text direction. Now, I need to adjust it for use with Right-To-Left (RTL) languages like Hebrew and Arabic.

When I try running Masonry with RTL text direction, the plugin still lays out the grid in a Left-To-Right format.

I've looked through the documentation, but there doesn't seem to be any setting specifically for dealing with RTL direction.

Does anyone have a solution for this issue?

Answer №1

In my opinion, the correct response is isOriginLeft: false as indicated on this website

Answer №2

To position the items on the right using CSS, you can simply float them to the right:

.masonry .item {
  float: right;
}

Next, adjust the option isOriginLeft: false in your JavaScript.

Check out this codepen example to see it in action:

http://codepen.io/anon/pen/gkCiG

Answer №3

Although it took me about two years to find a solution, I finally came across the answer provided by Masonry.

By using the isRTL option, you can arrange tiles from right to left:

$('.tile-view').masonry({ 
    columnWidth: 200,
    isRTL: true
});

Answer №4

StartFromRight

Determines the starting point for item positioning in the layout's horizontal flow. By default, items are positioned from the left with StartFromRight set to false. Change it to true for right-to-left layouts.

StartFromRight: true

Answer №5

If you are looking to create a right-to-left layout that includes images in your content, such as Bootstrap cards with images, then utilize the following code snippet for assistance.

Note: To implement this, make sure to have both Masonry and imagesLoaded libraries:

<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
//For more information, refer to the documentation: https://masonry.desandro.com/layout.html#imagesloaded
//Check out the demo here: https://codepen.io/desandro/pen/MwJoLQ
var grid = document.querySelector('.masonry');
var msnry;

imagesLoaded(grid, function () {
    // Initialize Masonry after all images have loaded
    msnry = new Masonry(grid, {
        // options
        percentPosition: true,
        originLeft: false
    });
});

Furthermore, due to the removal of Masonry from Bootstrap 5, the above instructions can serve as a helpful reference for those interested.

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

The FireBase dispatch functionality fails to update the real-time database

Struggling with a realtimeDB issue while using NuxtJS to manage state and send it to the DB. Saving data works fine, but editing results in a 400 BAD Request error. This error also occurs when trying to manually update information within Firebase realtime ...

Setting default values for Select2 input with tagging in ASP.NET MVC is a simple process that can greatly enhance the user experience

I am currently utilizing a Select2 input box as a tag controller in my view: CSHTML <input id="tagSelector" type="hidden" style="width: 300px"/> JS $('#tagSelector').select2({ placeholder: 'Select a tag...', ...

Detecting a click on the background div in Angular without capturing clicks on child divs

Over at ollynural.github.io, I've been working on creating a pop-up div in the portfolio page that provides additional information about the project you select. To close the pop-up, I have implemented an ng-click feature so that clicking on the main p ...

Comparing Ajax methods: Which one reigns supreme?

I am seeking advice on the best approach to handle a series of Ajax insert, update, and delete operations. Which method is more effective? Creating individual methods for each function (e.g., delete_foo, insert_foo, update_foo, delete_bar, insert_bar, ...

Unable to display image in jqGrid binary format

In our system, we use a standard function to retrieve images stored as binaries in the database, and this function works seamlessly throughout the entire system. However, when implementing jqGrid, I encountered difficulties using the existing structure as ...

How can I modify the base color of a cone in Three.js?

My cone in the jsfiddle link is currently all blue, but I want to change the color of the square base to red. To do that, I need to alter the color of the two faces that make up the square base. How can this be achieved? View my cone on JsFiddle: http://j ...

Instantly see changes without having to manually refresh the screen

I need help figuring out how to update my PHP webpage or table automatically in real-time without requiring a manual refresh. The current functionality of the page is working perfectly fine. Specifically, I want the page to instantly display any new user ...

Tips for responding to and disabling a specific button in Vuetify.js after clicking the follow or unfollow button

I have a situation where I need to implement a functionality for a series of buttons with follow and unfollow statuses. When a user clicks on any button, I want the status to change after a brief delay and deactivation, followed by reactivation. For instan ...

Implementing V-model within an iteration

I am encountering an issue while trying to utilize v-model within a v-for loop, resulting in an error message. Is there a solution to make this functionality work properly? <ul class=""> <li class="" v-model="category.data" v-for="category in ...

Ensure the background image completely fills the div, regardless of the image's aspect ratio

Can anyone help me figure out how to fill a div's background with an image, regardless of its aspect ratio (landscape or portrait)? I've tried different methods from using background-size: cover; to background-size: 100% 100%;, but the div doesn& ...

Ways to verify whether a vue instance is empty within a .vue file by utilizing the v-if directive

I am facing an issue with a for-loop in Vue that iterates through a media object using v-for to check if it contains any images. Everything is working correctly, but I want to display a div below the loop saying "There is no media" when the object is empty ...

What steps are involved in deploying a Vue.js application on a tomcat server?

Is it possible to deploy a vue.js application on a server using tomcat? If so, how can this be done? ...

Troubleshooting: Issues with locating CSS and JS files (404 error) while utilizing URL parameters within Django platform

I've designed a dashboard page that showcases various graphs. The page automatically updates the graph data every hour. You can access the page at the following URL: http://localhost/dashboard I'd like to give users the option to specify the ...

Automated submission feature for Angular scanning technology

As a newcomer to angular.js, I am dedicated to learning the ins and outs of the framework. Recently, I created a form that enables me to search using a barcode scanner, followed by pressing a submit button. However, I find this process redundant as I wou ...

An error was encountered when attempting to reference an external JavaScript script in the document

Could someone please provide guidance on how to utilize the document method in an external .js file within Visual Studio Code? This is what I have tried so far: I have created an index.html file: <!DOCTYPE html> <html lang="en"> <head> ...

Retrieve the selected checkboxes from the latest .change() trigger

I'm facing an issue with a basic question that I can't seem to find the right terms to research for help. The problem revolves around a .change() listener that monitors checkbox changes within a div (used to toggle Leaflet Map layers). My goal i ...

Replacing an array element in React.js

Here is a React.js code snippet where I am trying to utilize an array called distances from the file Constants.js in my Main.js file. Specifically, I want to replace the APT column in the sampleData with a suitable value from the array distances extracted ...

What is the best way to reset the scroll position of a div when you stop hovering over a link?

Can anyone help me figure out how to reset the scroll wheel when hovering over dropdown menu items? I've tried multiple solutions found online, but none seem to be working for me. If you have any ideas on how to accomplish this, please let me know! f ...

What is the quickest method for importing React.js Material Icons in a single line of code?

While working on my initial react.js project as a beginner, I encountered the frustration of having to import Material UI icons individually. This process made my code unnecessarily long and required me to repeatedly visit the browser to copy the icon li ...

Encountering redundant links during the scraping process

I'm currently working on extracting "a" tags with the class name "featured" from a specific website . Although the code I've written seems to be error-free, it unfortunately duplicates the links. How can I resolve this issue and avoid the duplica ...